liveness: Test interaction with automatically_derived attribute

This commit is contained in:
Tomasz Miąsko 2020-09-27 00:00:00 +00:00
parent 33dde94d33
commit 063d5e9d8b
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,38 @@
// Test for interaction between #[automatically_derived] attribute used by
// built-in derives and lints generated by liveness pass.
//
// edition:2018
// check-pass
#![warn(unused)]
pub trait T: Sized {
const N: usize;
fn t(&self) -> Self;
}
impl T for u32 {
const N: usize = {
let a = 0; // FIXME should warn about unused variable
4
};
fn t(&self) -> Self {
let b = 16; //~ WARN unused variable: `b`
0
}
}
#[automatically_derived]
impl T for i32 {
const N: usize = {
let c = 0;
4
};
fn t(&self) -> Self {
let d = 17;
0
}
}
fn main() {}

View file

@ -0,0 +1,15 @@
warning: unused variable: `b`
--> $DIR/liveness-derive.rs:20:13
|
LL | let b = 16;
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
note: the lint level is defined here
--> $DIR/liveness-derive.rs:6:9
|
LL | #![warn(unused)]
| ^^^^^^
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
warning: 1 warning emitted