Skip to content

Commit 975741c

Browse files
committed
add test for dead code caused by enum variants shadowing an associated function
1 parent fe5c95d commit 975741c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ check-pass
2+
#![warn(dead_code)]
3+
4+
enum E {
5+
F(),
6+
C(),
7+
}
8+
9+
impl E {
10+
#[expect(non_snake_case)]
11+
fn F() {}
12+
//~^ WARN: associated items `F` and `C` are never used
13+
14+
const C: () = ();
15+
}
16+
17+
fn main() {
18+
let _: E = E::F();
19+
let _: E = E::C();
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
warning: associated items `F` and `C` are never used
2+
--> $DIR/dead-code-associated-function.rs:11:8
3+
|
4+
LL | impl E {
5+
| ------ associated items in this implementation
6+
LL | #[expect(non_snake_case)]
7+
LL | fn F() {}
8+
| ^
9+
...
10+
LL | const C: () = ();
11+
| ^
12+
|
13+
note: the lint level is defined here
14+
--> $DIR/dead-code-associated-function.rs:2:9
15+
|
16+
LL | #![warn(dead_code)]
17+
| ^^^^^^^^^
18+
19+
warning: 1 warning emitted
20+

0 commit comments

Comments
 (0)