Code
#[allow(dead_code)]
trait Foo {
const FOO: u32;
}
impl Foo for u32 {
const FOO: u32 = roundtrip(0);
}
const fn roundtrip(x: u32) -> u32 {
x
}
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=1991c4121122ea00f92d73867bb5f048
Current output
warning: function `roundtrip` is never used
--> src/lib.rs:10:10
|
10 | const fn roundtrip(x: u32) -> u32 {
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
Desired output
No lint
Rationale and extra context
roundtrip is used in an instance of trait Foo so it isn't dead. Foo isn't used, but with it being allowed I don't think the check should propagate back elsewhere.
E.g. bar doesn't get a lint in this case:
#[allow(dead_code)]
const X: u32 = bar(0);
const fn bar(x: u32) -> u32 {
x
}
This regressed in #143519, cc @mu001999
Rust Version
searched nightlies: from nightly-2025-05-31 to nightly-2025-07-15
regressed nightly: nightly-2025-07-14
searched commit range: bfc046a...e9182f1
regressed commit: 56835d7
bisected with cargo-bisect-rustc v0.6.10
Host triple: aarch64-apple-darwin
Reproduce with:
cargo bisect-rustc --start 2025-05-31 --end 2025-07-15 --without-cargo --script=rustc -- a.rs
Code
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=1991c4121122ea00f92d73867bb5f048
Current output
Desired output
No lint
Rationale and extra context
roundtripis used in an instance oftrait Fooso it isn't dead.Fooisn't used, but with it beingallowed I don't think the check should propagate back elsewhere.E.g.
bardoesn't get a lint in this case:This regressed in #143519, cc @mu001999
Rust Version
searched nightlies: from nightly-2025-05-31 to nightly-2025-07-15
regressed nightly: nightly-2025-07-14
searched commit range: bfc046a...e9182f1
regressed commit: 56835d7
bisected with cargo-bisect-rustc v0.6.10
Host triple: aarch64-apple-darwin
Reproduce with:
cargo bisect-rustc --start 2025-05-31 --end 2025-07-15 --without-cargo --script=rustc -- a.rs