Add regression test
This commit is contained in:
parent
6214ef8a0f
commit
3c63f67802
12
src/test/ui/lint/issue-81314-unused-span-ident.fixed
Normal file
12
src/test/ui/lint/issue-81314-unused-span-ident.fixed
Normal file
@ -0,0 +1,12 @@
|
||||
// run-rustfix
|
||||
// Regression test for #81314: Unused variable lint should
|
||||
// span only the identifier and not the rest of the pattern
|
||||
|
||||
#![deny(unused)]
|
||||
|
||||
fn main() {
|
||||
let [_rest @ ..] = [1, 2, 3]; //~ ERROR unused variable
|
||||
}
|
||||
|
||||
pub fn foo([_rest @ ..]: &[i32]) { //~ ERROR unused variable
|
||||
}
|
12
src/test/ui/lint/issue-81314-unused-span-ident.rs
Normal file
12
src/test/ui/lint/issue-81314-unused-span-ident.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// run-rustfix
|
||||
// Regression test for #81314: Unused variable lint should
|
||||
// span only the identifier and not the rest of the pattern
|
||||
|
||||
#![deny(unused)]
|
||||
|
||||
fn main() {
|
||||
let [rest @ ..] = [1, 2, 3]; //~ ERROR unused variable
|
||||
}
|
||||
|
||||
pub fn foo([rest @ ..]: &[i32]) { //~ ERROR unused variable
|
||||
}
|
21
src/test/ui/lint/issue-81314-unused-span-ident.stderr
Normal file
21
src/test/ui/lint/issue-81314-unused-span-ident.stderr
Normal file
@ -0,0 +1,21 @@
|
||||
error: unused variable: `rest`
|
||||
--> $DIR/issue-81314-unused-span-ident.rs:8:10
|
||||
|
|
||||
LL | let [rest @ ..] = [1, 2, 3];
|
||||
| ^^^^ help: if this is intentional, prefix it with an underscore: `_rest`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-81314-unused-span-ident.rs:5:9
|
||||
|
|
||||
LL | #![deny(unused)]
|
||||
| ^^^^^^
|
||||
= note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`
|
||||
|
||||
error: unused variable: `rest`
|
||||
--> $DIR/issue-81314-unused-span-ident.rs:11:13
|
||||
|
|
||||
LL | pub fn foo([rest @ ..]: &[i32]) {
|
||||
| ^^^^ help: if this is intentional, prefix it with an underscore: `_rest`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
x
Reference in New Issue
Block a user