Skip to content

Conversation

@thestinger
Copy link
Contributor

No description provided.

@bors bors closed this Oct 18, 2013
@bors bors merged commit 28a6498 into rust-lang:master Oct 18, 2013
@thestinger thestinger deleted the rusti branch October 19, 2013 02:17
flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 18, 2024
…r=Manishearth

Compare trait references in `trait_duplication_in_bounds` correctly

Fixes rust-lang#13476
Fixes rust-lang#11067
Fixes rust-lang#9915
Fixes rust-lang#9626

Currently, the `trait_duplication_in_bounds` lints has a helper type for a trait reference that can be used for comparison and hashing, represented as `{trait: Res, generic_args: Vec<Res>}`. However, there are a lot of issues with this. For one, a `Res` can't represent e.g. references, slices, or lots of other types, as well as const generics and associated type equality. In those cases, the lint simply ignores them and has no way of checking if they're actually the same.

So, instead of using `Res` for this, use `SpanlessEq` and `SpanlessHash` for comparisons with the trait path for checking if there are duplicates.

However, using `SpanlessEq` as is alone lead to a false negative in the test. `std::clone::Clone` + `foo::Clone` wasn't recognized as a duplicate, because it has different segments. So this also adds a new "mode" to SpanlessEq which compares by final resolution. (I've been wondering if this can't just be the default but it's quite a large scale change as it affects a lot of lints and I haven't yet looked at all uses of it to see if there are lints that really do care about having exactly the same path segments).

Maybe an alternative would be to turn the hir types/consts into middle types/consts and compare them instead but I'm not sure there's really a good way to do that

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants