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

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Feb 9, 2024
added
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
and removed
A-diagnosticsArea: Messages for errors, warnings, and lints
on Feb 9, 2024
Urgau

Urgau commented on Feb 9, 2024

@Urgau
Member

This has just being fixed in nightly. See #118257.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @Urgau@fmease@charles-r-earp@Noratrieb

        Issue actions

          Implementing a trait for a type disables dead_code lint. · Issue #120826 · rust-lang/rust