Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
charles-r-earp opened this issue Feb 9, 2024 · 1 comment
Closed

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

charles-r-earp opened this issue Feb 9, 2024 · 1 comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@charles-r-earp
Copy link

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

@charles-r-earp charles-r-earp added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 9, 2024
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-diagnostics Area: Messages for errors, warnings, and lints labels Feb 9, 2024
@Urgau
Copy link
Member

Urgau commented Feb 9, 2024

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
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants