Skip to content

Commit ab9eed7

Browse files
committed
Add dead code note to reference-level explanation
1 parent ec14d07 commit ab9eed7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

text/0000-associated-const-underscore.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,28 @@ The following details are called out as being worth testing:
572572
}
573573
```
574574

575+
7. Underscore constants are not dead code, despite not being referenced.
576+
577+
```rust
578+
#![deny(dead_code)]
579+
580+
pub struct Struct;
581+
582+
const _: () = {
583+
let _ = Struct;
584+
};
585+
586+
impl Struct {
587+
const _: () = {
588+
let _ = Struct;
589+
};
590+
591+
const _: () = {
592+
struct Unused; // error: dead code
593+
};
594+
}
595+
```
596+
575597
# Drawbacks
576598
[drawbacks]: #drawbacks
577599

0 commit comments

Comments
 (0)