Skip to content

Commit d3465bc

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

File tree

2 files changed

+33
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)