Skip to content

Commit 58581eb

Browse files
committed
test redundant_locals in proc macros
1 parent b4379a4 commit 58581eb

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

tests/ui/redundant_locals.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
//@aux-build:proc_macros.rs
12
#![allow(unused, clippy::no_effect)]
23
#![warn(clippy::redundant_locals)]
34

5+
extern crate proc_macros;
6+
use proc_macros::{external, with_span};
7+
48
fn main() {}
59

610
fn immutable() {
@@ -94,4 +98,14 @@ fn macros() {
9498
}
9599

96100
rebind!(x);
101+
102+
external! {
103+
let x = 1;
104+
let x = x;
105+
}
106+
with_span! {
107+
span
108+
let x = 1;
109+
let x = x;
110+
}
97111
}

tests/ui/redundant_locals.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: redundant redefinition of a binding
2-
--> $DIR/redundant_locals.rs:7:9
2+
--> $DIR/redundant_locals.rs:11:9
33
|
44
LL | let x = 1;
55
| ^
@@ -10,7 +10,7 @@ LL | let x = x;
1010
= note: `-D clippy::redundant-locals` implied by `-D warnings`
1111

1212
error: redundant redefinition of a binding
13-
--> $DIR/redundant_locals.rs:12:9
13+
--> $DIR/redundant_locals.rs:16:9
1414
|
1515
LL | let mut x = 1;
1616
| ^^^^^
@@ -20,7 +20,7 @@ LL | let mut x = x;
2020
= help: remove the redefinition of `x`
2121

2222
error: redundant redefinition of a binding
23-
--> $DIR/redundant_locals.rs:33:14
23+
--> $DIR/redundant_locals.rs:37:14
2424
|
2525
LL | fn parameter(x: i32) {
2626
| ^
@@ -30,7 +30,7 @@ LL | let x = x;
3030
= help: remove the redefinition of `x`
3131

3232
error: redundant redefinition of a binding
33-
--> $DIR/redundant_locals.rs:38:9
33+
--> $DIR/redundant_locals.rs:42:9
3434
|
3535
LL | let x = 1;
3636
| ^
@@ -40,7 +40,7 @@ LL | let x = x;
4040
= help: remove the redefinition of `x`
4141

4242
error: redundant redefinition of a binding
43-
--> $DIR/redundant_locals.rs:39:9
43+
--> $DIR/redundant_locals.rs:43:9
4444
|
4545
LL | let x = x;
4646
| ^
@@ -50,7 +50,7 @@ LL | let x = x;
5050
= help: remove the redefinition of `x`
5151

5252
error: redundant redefinition of a binding
53-
--> $DIR/redundant_locals.rs:40:9
53+
--> $DIR/redundant_locals.rs:44:9
5454
|
5555
LL | let x = x;
5656
| ^
@@ -60,7 +60,7 @@ LL | let x = x;
6060
= help: remove the redefinition of `x`
6161

6262
error: redundant redefinition of a binding
63-
--> $DIR/redundant_locals.rs:41:9
63+
--> $DIR/redundant_locals.rs:45:9
6464
|
6565
LL | let x = x;
6666
| ^
@@ -70,7 +70,7 @@ LL | let x = x;
7070
= help: remove the redefinition of `x`
7171

7272
error: redundant redefinition of a binding
73-
--> $DIR/redundant_locals.rs:46:9
73+
--> $DIR/redundant_locals.rs:50:9
7474
|
7575
LL | let a = 1;
7676
| ^
@@ -81,7 +81,7 @@ LL | let a = a;
8181
= help: remove the redefinition of `a`
8282

8383
error: redundant redefinition of a binding
84-
--> $DIR/redundant_locals.rs:47:9
84+
--> $DIR/redundant_locals.rs:51:9
8585
|
8686
LL | let b = 2;
8787
| ^
@@ -92,7 +92,7 @@ LL | let b = b;
9292
= help: remove the redefinition of `b`
9393

9494
error: redundant redefinition of a binding
95-
--> $DIR/redundant_locals.rs:54:13
95+
--> $DIR/redundant_locals.rs:58:13
9696
|
9797
LL | let x = 1;
9898
| ^
@@ -102,7 +102,7 @@ LL | let x = x;
102102
= help: remove the redefinition of `x`
103103

104104
error: redundant redefinition of a binding
105-
--> $DIR/redundant_locals.rs:61:13
105+
--> $DIR/redundant_locals.rs:65:13
106106
|
107107
LL | let x = 1;
108108
| ^
@@ -112,7 +112,7 @@ LL | let x = x;
112112
= help: remove the redefinition of `x`
113113

114114
error: redundant redefinition of a binding
115-
--> $DIR/redundant_locals.rs:64:6
115+
--> $DIR/redundant_locals.rs:68:6
116116
|
117117
LL | |x: i32| {
118118
| ^
@@ -122,7 +122,7 @@ LL | let x = x;
122122
= help: remove the redefinition of `x`
123123

124124
error: redundant redefinition of a binding
125-
--> $DIR/redundant_locals.rs:81:9
125+
--> $DIR/redundant_locals.rs:85:9
126126
|
127127
LL | let x = 1;
128128
| ^

0 commit comments

Comments
 (0)