Skip to content

Implementing a trait for a type disables dead_code lint. #120826

Closed
@charles-r-earp

Description

@charles-r-earp

Code

trait Zoom {}

struct Foo;
struct Bar;

impl Zoom for Foo {}

Current output

Compiling playground v0.0.1 (/playground)
warning: struct `Bar` is never constructed
 --> src/lib.rs:4:8
  |
4 | struct Bar;
  |        ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: `playground` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.25s

Desired output

Compiling playground v0.0.1 (/playground)
warning: struct `Foo` is never constructed
 --> src/lib.rs:3:8
  |
3 | struct Foo;
  |        ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: struct `Bar` is never constructed
 --> src/lib.rs:4:8
  |
4 | struct Bar;
  |        ^^^

warning: `playground` (lib) generated 2 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.26s

Rationale and extra context

No response

Other cases

No response

Rust Version

stable 1.76.0

Anything else?

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f9122e0d0aaecb171c6fded1d8589f19

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions