Add regression test

This commit is contained in:
Giacomo Stevanato 2021-02-28 21:03:44 +01:00
parent 6214ef8a0f
commit 3c63f67802
3 changed files with 45 additions and 0 deletions

View 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
}

View 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
}

View 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