Merge pull request #316 from Manishearth/mutmut

Fix mut_mut false positive, make Allow (fixes #309)
This commit is contained in:
llogiq 2015-09-07 23:22:30 +02:00
commit b5d953bf7d
4 changed files with 10 additions and 4 deletions

View File

@ -33,7 +33,7 @@ name
[match_ref_pats](https://github.com/Manishearth/rust-clippy/wiki#match_ref_pats) | warn | a match has all arms prefixed with `&`; the match expression can be dereferenced instead
[min_max](https://github.com/Manishearth/rust-clippy/wiki#min_max) | warn | `min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant
[modulo_one](https://github.com/Manishearth/rust-clippy/wiki#modulo_one) | warn | taking a number modulo 1, which always returns 0
[mut_mut](https://github.com/Manishearth/rust-clippy/wiki#mut_mut) | warn | usage of double-mut refs, e.g. `&mut &mut ...` (either copy'n'paste error, or shows a fundamental misunderstanding of references)
[mut_mut](https://github.com/Manishearth/rust-clippy/wiki#mut_mut) | allow | usage of double-mut refs, e.g. `&mut &mut ...` (either copy'n'paste error, or shows a fundamental misunderstanding of references)
[needless_bool](https://github.com/Manishearth/rust-clippy/wiki#needless_bool) | warn | if-statements with plain booleans in the then- and else-clause, e.g. `if p { true } else { false }`
[needless_lifetimes](https://github.com/Manishearth/rust-clippy/wiki#needless_lifetimes) | warn | using explicit lifetimes for references in function arguments when elision rules would allow omitting them
[needless_range_loop](https://github.com/Manishearth/rust-clippy/wiki#needless_range_loop) | warn | for-looping over a range of indices where an iterator over items would do

View File

@ -92,6 +92,7 @@ pub fn plugin_registrar(reg: &mut Registry) {
methods::OPTION_UNWRAP_USED,
methods::RESULT_UNWRAP_USED,
methods::WRONG_PUB_SELF_CONVENTION,
mut_mut::MUT_MUT,
ptr_arg::PTR_ARG,
shadow::SHADOW_REUSE,
shadow::SHADOW_SAME,
@ -135,7 +136,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
misc::MODULO_ONE,
misc::REDUNDANT_PATTERN,
misc::TOPLEVEL_REF_ARG,
mut_mut::MUT_MUT,
needless_bool::NEEDLESS_BOOL,
precedence::PRECEDENCE,
ranges::RANGE_STEP_BY_ZERO,

View File

@ -4,7 +4,7 @@ use rustc::middle::ty::{TypeAndMut, TyRef};
use utils::{in_external_macro, span_lint};
declare_lint!(pub MUT_MUT, Warn,
declare_lint!(pub MUT_MUT, Allow,
"usage of double-mut refs, e.g. `&mut &mut ...` (either copy'n'paste error, \
or shows a fundamental misunderstanding of references)");
@ -53,7 +53,6 @@ fn check_expr_mut(cx: &Context, expr: &Expr) {
fn unwrap_mut(ty : &Ty) -> Option<&Ty> {
match ty.node {
TyPtr(MutTy{ ty: ref pty, mutbl: MutMutable }) => Option::Some(pty),
TyRptr(_, MutTy{ ty: ref pty, mutbl: MutMutable }) => Option::Some(pty),
_ => Option::None
}

View File

@ -1,6 +1,8 @@
#![feature(plugin)]
#![plugin(clippy)]
#![allow(unused)]
//#![plugin(regex_macros)]
//extern crate regex;
@ -9,6 +11,11 @@ fn fun(x : &mut &mut u32) -> bool { //~ERROR generally you want to avoid `&mut &
**x > 0
}
#[deny(mut_mut)]
fn less_fun(x : *mut *mut u32) {
let y = x;
}
macro_rules! mut_ptr {
($p:expr) => { &mut $p }
}