Skip to content

Commit

Permalink
liveness: Test interaction with automatically_derived attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiasko committed Sep 27, 2020
1 parent 33dde94 commit 063d5e9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/test/ui/liveness/liveness-derive.rs
Original file line number Diff line number Diff line change
@@ -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() {}
15 changes: 15 additions & 0 deletions src/test/ui/liveness/liveness-derive.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 063d5e9

Please sign in to comment.