Not sure if this is an issue with dead_code or unfulfilled_lint_expectations, but the below code does not compile:
#![deny(dead_code, unfulfilled_lint_expectations, reason = "example")]
#![expect(dead_code, reason = "example")]
struct Foo;
impl Foo {}
[zack@laptop foo]$ cargo check
Checking foo v0.1.0 (/home/zack/projects/foo)
error: this lint expectation is unfulfilled
--> src/lib.rs:2:11
|
2 | #![expect(dead_code, reason = "example")]
| ^^^^^^^^^
|
= note: example
= note: example
note: the lint level is defined here
--> src/lib.rs:1:20
|
1 | #![deny(dead_code, unfulfilled_lint_expectations, reason = "example")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: could not compile `foo` (lib) due to 1 previous error
If you remove impl Foo {}, change expect to allow, or use expect only on Foo (i.e., don't use expect on the crate or mod level); then it compiles. If you remove the expect line altogether, the code doesn't compile showing that dead_code is triggered:
[zack@laptop foo]$ cargo check
Checking foo v0.1.0 (/home/zack/projects/foo)
error: struct `Foo` is never constructed
--> src/lib.rs:2:8
|
2 | struct Foo;
| ^^^
|
= note: example
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![deny(dead_code, unfulfilled_lint_expectations, reason = "example")]
| ^^^^^^^^^
error: could not compile `foo` (lib) due to 1 previous error
The original bug was reported on URLO where the silly empty impl Foo is a Clone impl.
System Info:
[zack@laptop ~]$ rustc -V
rustc 1.94.0 (4a4ef493e 2026-03-02)
[zack@laptop ~]$ uname -a
Linux laptop 6.19.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 14 Mar 2026 01:07:43 +0000 x86_64 GNU/Linux
Not sure if this is an issue with
dead_codeorunfulfilled_lint_expectations, but the below code does not compile:[zack@laptop foo]$ cargo check Checking foo v0.1.0 (/home/zack/projects/foo) error: this lint expectation is unfulfilled --> src/lib.rs:2:11 | 2 | #![expect(dead_code, reason = "example")] | ^^^^^^^^^ | = note: example = note: example note: the lint level is defined here --> src/lib.rs:1:20 | 1 | #![deny(dead_code, unfulfilled_lint_expectations, reason = "example")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: could not compile `foo` (lib) due to 1 previous errorIf you remove
impl Foo {}, changeexpecttoallow, or useexpectonly onFoo(i.e., don't useexpecton the crate ormodlevel); then it compiles. If you remove theexpectline altogether, the code doesn't compile showing thatdead_codeis triggered:[zack@laptop foo]$ cargo check Checking foo v0.1.0 (/home/zack/projects/foo) error: struct `Foo` is never constructed --> src/lib.rs:2:8 | 2 | struct Foo; | ^^^ | = note: example note: the lint level is defined here --> src/lib.rs:1:9 | 1 | #![deny(dead_code, unfulfilled_lint_expectations, reason = "example")] | ^^^^^^^^^ error: could not compile `foo` (lib) due to 1 previous errorThe original bug was reported on URLO where the silly empty
impl Foois aCloneimpl.System Info: