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

Unused variable warning for default trait methods #92696

Closed
CryZe opened this issue Jan 9, 2022 · 2 comments
Closed

Unused variable warning for default trait methods #92696

CryZe opened this issue Jan 9, 2022 · 2 comments
Labels
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.

Comments

@CryZe
Copy link
Contributor

CryZe commented Jan 9, 2022

Given the following code: Playground

pub trait AutoSplitter {
    type Data;
    fn update(&mut self) -> Option<Self::Data>;
    fn should_start(data: &Self::Data) -> bool {
        false
    }
}

The current output is:

warning: unused variable: `data`
 --> src/lib.rs:4:21
  |
4 |     fn should_start(data: &Self::Data) -> bool {
  |                     ^^^^ help: if this is intentional, prefix it with an underscore: `_data`
  |
  = note: `#[warn(unused_variables)]` on by default

Ideally the compiler should not emit any warnings as prefixing the parameter with an underscore would negatively affect the documentation and auto generated implementations via an IDE / rust-analyzer.

@CryZe CryZe 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 Jan 9, 2022
@ehuss
Copy link
Contributor

ehuss commented Jan 10, 2022

I believe this is a duplicate of #64723, #26487, and #14027. Per #26487 (comment), it sounds like the lang team would prefer to not make this change.

@ehuss
Copy link
Contributor

ehuss commented Jul 27, 2023

Closing as a duplicate of the above linked issues.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

2 participants