about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/back/write.rs
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-13 15:15:57 +0200
committerGitHub <noreply@github.com>2025-07-13 15:15:57 +0200
commit7e0721b79881fc9bddb713f7237e7dae132e9f79 (patch)
treebdf936f4faa1630e3c925be642d6ccc76fb86b4a /compiler/rustc_codegen_llvm/src/back/write.rs
parentb56880ce628839acd4c5bd1e86475b910a5a5076 (diff)
parent889582e704e516ab22a685711ef593a98fd9021a (diff)
downloadrust-7e0721b79881fc9bddb713f7237e7dae132e9f79.tar.gz
rust-7e0721b79881fc9bddb713f7237e7dae132e9f79.zip
Rollup merge of #143519 - mu001999-contrib:dead-code/impl-items, r=petrochenkov
Check assoc consts and tys later like assoc fns

This PR
1. checks assoc consts and tys later like assoc fns
2. marks assoc consts appear in poly-trait-ref live

For assoc consts, considering
```rust
#![deny(dead_code)]

trait Tr { // ERROR trait `Tr` is never used
    const I: Self;
}

struct Foo; //~ ERROR struct `Foo` is never constructed

impl Tr for Foo {
    const I: Self = Foo;
}

fn main() {}
```

Current this will produce unused `I` instead of unused `Tr` and `Foo` ([play](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=e0490d4a2d522cb70437b26e514a3d9c)), because `const I: Self = Foo;` will be added into the worklist at first:
```
error: associated constant `I` is never used
 --> src/main.rs:4:11
  |
3 | trait Tr { // ERROR trait `Tr` is never used
  |       -- associated constant in this trait
4 |     const I: Self;
  |           ^
  |
note: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![deny(dead_code)]
  |         ^^^^^^^^^

error: could not compile `playground` (bin "playground") due to 1 previous error
```

This also happens to assoc tys, see the [new test](https://github.com/rust-lang/rust/compare/master...mu001999-contrib:rust:dead-code/impl-items?expand=1#diff-bf45fa403934a31c9d610a073ed2603d885e7e81572e8edf38b7f4e08a1f3531)

Fixes rust-lang/rust#126729

r? `````@petrochenkov`````
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/back/write.rs')
0 files changed, 0 insertions, 0 deletions