Skip to content

Commit f2667ec

Browse files
authored
Rollup merge of #161442 - zakrad:regr-test-59333, r=JonathanBrouwer
Add regression test for dead code on type alias used in impl self type Closes #59333
2 parents 7c7ec67 + 8ba038c commit f2667ec

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//@ check-pass
2+
//! Regression test for <https://github.com/rust-lang/rust/issues/59333>.
3+
//! A type alias used only as (part of) the self type of an impl was
4+
//! incorrectly flagged as dead code.
5+
6+
#![deny(dead_code)]
7+
8+
struct Runner;
9+
10+
type RuntimeImpl = Runner;
11+
12+
trait Runtime {
13+
fn run(&mut self);
14+
}
15+
16+
impl Runtime for &mut RuntimeImpl {
17+
fn run(&mut self) {}
18+
}
19+
20+
struct Walker;
21+
22+
type WalkerImpl = Walker;
23+
24+
trait Walk {
25+
fn walk(&self) {}
26+
}
27+
28+
impl Walk for WalkerImpl {}
29+
30+
fn main() {
31+
let mut runner = Runner;
32+
(&mut runner).run();
33+
Walker.walk();
34+
}

0 commit comments

Comments
 (0)