File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ declare_lint_pass!(UnnecessaryMutPassed => [UNNECESSARY_MUT_PASSED]);
3737
3838impl < ' tcx > LateLintPass < ' tcx > for UnnecessaryMutPassed {
3939 fn check_expr ( & mut self , cx : & LateContext < ' tcx > , e : & ' tcx Expr < ' _ > ) {
40+ if e. span . from_expansion ( ) {
41+ // Issue #11268
42+ return ;
43+ }
44+
4045 match e. kind {
4146 ExprKind :: Call ( fn_expr, arguments) => {
4247 if let ExprKind :: Path ( ref path) = fn_expr. kind {
Original file line number Diff line number Diff line change 1- #![ allow( unused_variables) ]
1+ #![ allow( unused_variables, dead_code ) ]
22
33fn takes_an_immutable_reference ( a : & i32 ) { }
44fn takes_a_mutable_reference ( a : & mut i32 ) { }
55
6+ mod issue11268 {
7+ macro_rules! x {
8+ ( $f: expr) => {
9+ $f( & mut 1 ) ;
10+ } ;
11+ }
12+
13+ fn f ( ) {
14+ x ! ( super :: takes_an_immutable_reference) ;
15+ x ! ( super :: takes_a_mutable_reference) ;
16+ }
17+ }
18+
619struct MyStruct ;
720
821impl MyStruct {
Original file line number Diff line number Diff line change 11error: the function `takes_an_immutable_reference` doesn't need a mutable reference
2- --> $DIR/mut_reference.rs:17 :34
2+ --> $DIR/mut_reference.rs:30 :34
33 |
44LL | takes_an_immutable_reference(&mut 42);
55 | ^^^^^^^
66 |
77 = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings`
88
99error: the function `as_ptr` doesn't need a mutable reference
10- --> $DIR/mut_reference.rs:19 :12
10+ --> $DIR/mut_reference.rs:32 :12
1111 |
1212LL | as_ptr(&mut 42);
1313 | ^^^^^^^
1414
1515error: the method `takes_an_immutable_reference` doesn't need a mutable reference
16- --> $DIR/mut_reference.rs:23 :44
16+ --> $DIR/mut_reference.rs:36 :44
1717 |
1818LL | my_struct.takes_an_immutable_reference(&mut 42);
1919 | ^^^^^^^
2020
2121error: this argument is a mutable reference, but not used mutably
22- --> $DIR/mut_reference.rs:11 :44
22+ --> $DIR/mut_reference.rs:24 :44
2323 |
2424LL | fn takes_a_mutable_reference(&self, a: &mut i32) {}
2525 | ^^^^^^^^ help: consider changing to: `&i32`
You can’t perform that action at this time.
0 commit comments