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

lint for redundant trait bounds (due to trait inheritance) #9197

Closed
thestinger opened this issue Sep 14, 2013 · 9 comments
Closed

lint for redundant trait bounds (due to trait inheritance) #9197

thestinger opened this issue Sep 14, 2013 · 9 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-needs-test Call for participation: Writing correctness tests.

Comments

@thestinger
Copy link
Contributor

We should give a warning that the Foo bound is redundant:

trait Foo {}
trait Bar: Foo {}

fn foo<T: Foo + Bar>() {}
@sfackler
Copy link
Member

We don't currently warn for even more obvious redundant bounds as well:

trait Foo {}

fn foo<T: Foo+Foo>() {}

@Aatch
Copy link
Contributor

Aatch commented Mar 4, 2014

Visiting for triage.

Still doesn't warn.

@Aatch Aatch added the E-mentor label Mar 4, 2014
@pongad
Copy link
Contributor

pongad commented Apr 13, 2014

Interested in trying, will find @thestinger on IRC.

@pongad
Copy link
Contributor

pongad commented Apr 19, 2014

Actually...who's mentoring this?
I'm still at a loss of what to do. xD

@reem
Copy link
Contributor

reem commented Dec 8, 2014

Triage: This errors now!

Should be closed.

@ghost ghost added the E-needs-test Call for participation: Writing correctness tests. label Dec 9, 2014
@tamird
Copy link
Contributor

tamird commented Dec 23, 2014

@reem the trivial case errors, but the original case reported here still doesn't

tamird added a commit to tamird/rust that referenced this issue Dec 28, 2014
tamird added a commit to tamird/rust that referenced this issue Dec 30, 2014
@tamird
Copy link
Contributor

tamird commented Mar 15, 2015

This should either be closed or the E-needstest label removed. Here's a case that demonstrates the problem:

trait Foo {
  fn noop(&self) {}
}

trait Bar: Foo {}

#[allow(dead_code)]
fn bar<T: Foo + Bar>() {}

fn main() {}

@frewsxcv
Copy link
Member

It looks like there is no error nor warning for redundant traits

http://is.gd/iqumGL

@steveklabnik
Copy link
Member

Since new lints have a big impact on users of rustc, the policy is that they should go through the RFC process like other user-facing changes. As such, I'm going to give this one a close, but if anyone comes across this ticket and wants this lint, consider adding it to clippy and/or writing up an RFC. Thanks!

tamird added a commit to tamird/rust that referenced this issue Nov 18, 2017
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 6, 2022
* Allowing `unsafe_removed_from_name` on imports produces a false
positive on `useless_attribute`.

Fixes: rust-lang#9197

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 6, 2022
lint::unsafe_removed_from_name: fix false positive result when allowed

changelog: [`unsafe_removed_from_name`] Fix allowing on imports produces a false positive on `useless_attribute`.

Fixes: rust-lang#9197

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
tamird added a commit to tamird/rust that referenced this issue Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-needs-test Call for participation: Writing correctness tests.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants