diff --git a/README.md b/README.md index 060eac942ba..ca96e496bfe 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/lib.rs b/src/lib.rs index fdb0f975109..7ce2be97358 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, diff --git a/src/mut_mut.rs b/src/mut_mut.rs index b6260bb8ecc..d3270861870 100644 --- a/src/mut_mut.rs +++ b/src/mut_mut.rs @@ -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 } diff --git a/tests/compile-fail/mut_mut.rs b/tests/compile-fail/mut_mut.rs index 8aa47769539..2560a54c0ef 100755 --- a/tests/compile-fail/mut_mut.rs +++ b/tests/compile-fail/mut_mut.rs @@ -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 } }