Skip to content

dead_code false positive for const used in definition of tuple struct #56281

Closed
@crumblingstatue

Description

@crumblingstatue
const LEN: usize = 4;

#[derive(Debug)]
struct Wrapper([u8; LEN]);

fn main() {
    println!("{:?}", Wrapper([0, 1, 2, 3]));
}
warning: constant item is never used: `LEN`
 --> src/main.rs:1:1
  |
1 | const LEN: usize = 4;
  | ^^^^^^^^^^^^^^^^^^^^^

If the struct is a record struct with a named field, the false positive doesn't trigger.

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions