diff options
| author | bors <bors@rust-lang.org> | 2020-09-29 19:25:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-09-29 19:25:10 +0000 |
| commit | 381b445ff5751f9f39ec672b623372dff09c276e (patch) | |
| tree | 5b6a16984d37853458ad3d9000df188dca01f238 /src | |
| parent | 9b77a6a20021cb8783111c04e9260963f15b550e (diff) | |
| parent | 063d5e9d8bdf9f0b26817265ca90e246bb20e379 (diff) | |
| download | rust-381b445ff5751f9f39ec672b623372dff09c276e.tar.gz rust-381b445ff5751f9f39ec672b623372dff09c276e.zip | |
Auto merge of #77274 - tmiasko:liveness-cnd, r=lcnr
Liveness refactoring continued * Move body_owner field from IrMaps to Liveness (the only user of the field). * Use upvars instead of FnKind to check for closures (avoids FnKind, will be useful when checking all bodies, not just fns). * Use visit_param to add variables corresponding to params. * Store upvars_mentioned inside Liveness struct. * Inline visitor implementation for IrMaps, avoiding unnecessary indirection. * Test interaction with automatically_derived attribute (not covered by any of existing tests). No functional changes intended.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/liveness/liveness-derive.rs | 38 | ||||
| -rw-r--r-- | src/test/ui/liveness/liveness-derive.stderr | 15 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/liveness/liveness-derive.rs b/src/test/ui/liveness/liveness-derive.rs new file mode 100644 index 00000000000..66d0b7090ff --- /dev/null +++ b/src/test/ui/liveness/liveness-derive.rs @@ -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() {} diff --git a/src/test/ui/liveness/liveness-derive.stderr b/src/test/ui/liveness/liveness-derive.stderr new file mode 100644 index 00000000000..d4f45a0a313 --- /dev/null +++ b/src/test/ui/liveness/liveness-derive.stderr @@ -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 + |
