Add regression test showing we don't realize some consts are used
This commit is contained in:
parent
f47ad71059
commit
8f09abb497
4 changed files with 33 additions and 8 deletions
|
@ -29,6 +29,7 @@ const used_const: isize = 0;
|
|||
pub const used_const2: isize = used_const;
|
||||
const USED_CONST: isize = 1;
|
||||
const CONST_USED_IN_ENUM_DISCRIMINANT: isize = 11;
|
||||
const CONST_USED_IN_RANGE_PATTERN: isize = 12;
|
||||
|
||||
pub type typ = *const UsedStruct4;
|
||||
pub struct PubStruct;
|
||||
|
@ -81,6 +82,7 @@ pub fn pub_fn() {
|
|||
match i {
|
||||
USED_STATIC => (),
|
||||
USED_CONST => (),
|
||||
CONST_USED_IN_RANGE_PATTERN..100 => {}
|
||||
_ => ()
|
||||
}
|
||||
f::<StructUsedInGeneric>();
|
||||
|
|
|
@ -17,19 +17,19 @@ LL | const priv_const: isize = 0;
|
|||
| ^^^^^^^^^^
|
||||
|
||||
error: struct `PrivStruct` is never constructed
|
||||
--> $DIR/lint-dead-code-1.rs:35:8
|
||||
--> $DIR/lint-dead-code-1.rs:36:8
|
||||
|
|
||||
LL | struct PrivStruct;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: enum `priv_enum` is never used
|
||||
--> $DIR/lint-dead-code-1.rs:64:6
|
||||
--> $DIR/lint-dead-code-1.rs:65:6
|
||||
|
|
||||
LL | enum priv_enum { foo2, bar2 }
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: variant `bar3` is never constructed
|
||||
--> $DIR/lint-dead-code-1.rs:67:5
|
||||
--> $DIR/lint-dead-code-1.rs:68:5
|
||||
|
|
||||
LL | enum used_enum {
|
||||
| --------- variant in this enum
|
||||
|
@ -38,25 +38,25 @@ LL | bar3
|
|||
| ^^^^
|
||||
|
||||
error: function `priv_fn` is never used
|
||||
--> $DIR/lint-dead-code-1.rs:88:4
|
||||
--> $DIR/lint-dead-code-1.rs:90:4
|
||||
|
|
||||
LL | fn priv_fn() {
|
||||
| ^^^^^^^
|
||||
|
||||
error: function `foo` is never used
|
||||
--> $DIR/lint-dead-code-1.rs:93:4
|
||||
--> $DIR/lint-dead-code-1.rs:95:4
|
||||
|
|
||||
LL | fn foo() {
|
||||
| ^^^
|
||||
|
||||
error: function `bar` is never used
|
||||
--> $DIR/lint-dead-code-1.rs:98:4
|
||||
--> $DIR/lint-dead-code-1.rs:100:4
|
||||
|
|
||||
LL | fn bar() {
|
||||
| ^^^
|
||||
|
||||
error: function `baz` is never used
|
||||
--> $DIR/lint-dead-code-1.rs:102:4
|
||||
--> $DIR/lint-dead-code-1.rs:104:4
|
||||
|
|
||||
LL | fn baz() -> impl Copy {
|
||||
| ^^^
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//@ run-pass
|
||||
#![deny(dead_code)]
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub enum Foo {
|
||||
|
@ -11,6 +11,7 @@ impl Foo {
|
|||
const A2: Foo = Self::FooA(());
|
||||
const A3: Self = Foo::FooA(());
|
||||
const A4: Self = Self::FooA(());
|
||||
const A5: u32 = 1; //~ ERROR: dead_code
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -35,4 +36,9 @@ fn main() {
|
|||
Foo::A4 => {},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
match 3 {
|
||||
Foo::A5..5 => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
17
tests/ui/pattern/issue-110508.stderr
Normal file
17
tests/ui/pattern/issue-110508.stderr
Normal file
|
@ -0,0 +1,17 @@
|
|||
error: associated constant `A5` is never used
|
||||
--> $DIR/issue-110508.rs:14:11
|
||||
|
|
||||
LL | impl Foo {
|
||||
| -------- associated constant in this implementation
|
||||
...
|
||||
LL | const A5: u32 = 1;
|
||||
| ^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-110508.rs:1:9
|
||||
|
|
||||
LL | #![deny(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue