-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
liveness: Test interaction with automatically_derived attribute
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|