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

Function arguments in trait functions are "unused" if unused in default impl #55070

Closed
birkenfeld opened this issue Oct 14, 2018 · 3 comments
Closed
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@birkenfeld
Copy link
Contributor

E.g.

trait Foo {
    fn frob(id: usize) -> Option<usize> { None }
}

triggers "unused variable: id".

I would argue that this shouldn't trigger the lint, since it isn't triggered either when there is no default impl. The argument name has two roles here, one of which the lint doesn't consider.

@birkenfeld birkenfeld changed the title Function arguments in trait functions are "unused" considering default impl Function arguments in trait functions are "unused" if unused in default impl Oct 14, 2018
@sfackler
Copy link
Member

Duplicate of #26487.

@estebank estebank added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Aug 5, 2019
@estebank
Copy link
Contributor

estebank commented Aug 5, 2019

Current output is the same:

warning: unused variable: `id`
 --> file5.rs:2:13
  |
2 |     fn frob(id: usize) -> Option<usize> { None }
  |             ^^ help: consider prefixing with an underscore: `_id`
  |
  = note: `#[warn(unused_variables)]` on by default

As per #26487 (comment), this is not something we would like to change, but I'll let @rust-lang/lang decide whether that is still the case and close, or prioritize.

@Centril
Copy link
Contributor

Centril commented Aug 5, 2019

I'm a bit conflicted but ultimately I agree with the prior consensus. It seems to me nothing has changed from before and that #[allow(...)] (enhanced by #60406) or let _ = id; works.

@Centril Centril closed this as completed Aug 5, 2019
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 21, 2024
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-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants