Skip to content

Commit 3c63f67

Browse files
committed
Add regression test
1 parent 6214ef8 commit 3c63f67

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// run-rustfix
2+
// Regression test for #81314: Unused variable lint should
3+
// span only the identifier and not the rest of the pattern
4+
5+
#![deny(unused)]
6+
7+
fn main() {
8+
let [_rest @ ..] = [1, 2, 3]; //~ ERROR unused variable
9+
}
10+
11+
pub fn foo([_rest @ ..]: &[i32]) { //~ ERROR unused variable
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// run-rustfix
2+
// Regression test for #81314: Unused variable lint should
3+
// span only the identifier and not the rest of the pattern
4+
5+
#![deny(unused)]
6+
7+
fn main() {
8+
let [rest @ ..] = [1, 2, 3]; //~ ERROR unused variable
9+
}
10+
11+
pub fn foo([rest @ ..]: &[i32]) { //~ ERROR unused variable
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: unused variable: `rest`
2+
--> $DIR/issue-81314-unused-span-ident.rs:8:10
3+
|
4+
LL | let [rest @ ..] = [1, 2, 3];
5+
| ^^^^ help: if this is intentional, prefix it with an underscore: `_rest`
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/issue-81314-unused-span-ident.rs:5:9
9+
|
10+
LL | #![deny(unused)]
11+
| ^^^^^^
12+
= note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`
13+
14+
error: unused variable: `rest`
15+
--> $DIR/issue-81314-unused-span-ident.rs:11:13
16+
|
17+
LL | pub fn foo([rest @ ..]: &[i32]) {
18+
| ^^^^ help: if this is intentional, prefix it with an underscore: `_rest`
19+
20+
error: aborting due to 2 previous errors
21+

0 commit comments

Comments
 (0)