]> git.lizzy.rs Git - rust.git/commitdiff
Fix mut_mut false positive, make Allow (fixes #309)
authorManish Goregaokar <manishsmail@gmail.com>
Mon, 7 Sep 2015 20:58:15 +0000 (02:28 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Mon, 7 Sep 2015 20:59:13 +0000 (02:29 +0530)
README.md
src/lib.rs
src/mut_mut.rs
tests/compile-fail/mut_mut.rs

index 060eac942ba3ac1cf8077d1e46f2bdb296560fab..ca96e496bfe84d7f276cf7cfde6df98ebf149398 100644 (file)
--- 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
index fdb0f9751092de1623e1bd6e56e79453c098e446..7ce2be97358d7d89483c8d91366d278f449d26e2 100755 (executable)
@@ -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,
index b6260bb8eccddb4e81672275eddef573cc6ed7df..d3270861870f543baeb8827c362f33a4ddfaab5f 100644 (file)
@@ -4,7 +4,7 @@
 
 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 unwrap_addr(expr : &Expr) -> Option<&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
     }
index 8aa47769539418a4aeffc583e618c5549389eda8..2560a54c0ef7f75288a589fccbc057d1c63be86e 100755 (executable)
@@ -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 }
 }