File tree 3 files changed +23
-5
lines changed
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]);
37
37
38
38
impl < ' tcx > LateLintPass < ' tcx > for UnnecessaryMutPassed {
39
39
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , e : & ' tcx Expr < ' _ > ) {
40
+ if e. span . from_expansion ( ) {
41
+ // Issue #11268
42
+ return ;
43
+ }
44
+
40
45
match e. kind {
41
46
ExprKind :: Call ( fn_expr, arguments) => {
42
47
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 ) ]
2
2
3
3
fn takes_an_immutable_reference ( a : & i32 ) { }
4
4
fn takes_a_mutable_reference ( a : & mut i32 ) { }
5
5
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
+
6
19
struct MyStruct ;
7
20
8
21
impl MyStruct {
Original file line number Diff line number Diff line change 1
1
error: 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
3
3
|
4
4
LL | takes_an_immutable_reference(&mut 42);
5
5
| ^^^^^^^
6
6
|
7
7
= note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings`
8
8
9
9
error: the function `as_ptr` doesn't need a mutable reference
10
- --> $DIR/mut_reference.rs:19 :12
10
+ --> $DIR/mut_reference.rs:32 :12
11
11
|
12
12
LL | as_ptr(&mut 42);
13
13
| ^^^^^^^
14
14
15
15
error: 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
17
17
|
18
18
LL | my_struct.takes_an_immutable_reference(&mut 42);
19
19
| ^^^^^^^
20
20
21
21
error: this argument is a mutable reference, but not used mutably
22
- --> $DIR/mut_reference.rs:11 :44
22
+ --> $DIR/mut_reference.rs:24 :44
23
23
|
24
24
LL | fn takes_a_mutable_reference(&self, a: &mut i32) {}
25
25
| ^^^^^^^^ help: consider changing to: `&i32`
You can’t perform that action at this time.
0 commit comments