about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/errors.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-13 17:05:03 +0000
committerbors <bors@rust-lang.org>2024-02-13 17:05:03 +0000
commit3e264ba13ac0e6c819101d3979ddb7d243cbf0dd (patch)
tree793888465ac4254f3d25859565bbc73b7ef16fae /compiler/rustc_codegen_llvm/src/errors.rs
parent3e3a09e2bb26ba3b8207019ea53fd9d7da4831d3 (diff)
parent92616c0aaac07bf589a2d40502dd5dec804e8318 (diff)
downloadrust-3e264ba13ac0e6c819101d3979ddb7d243cbf0dd.tar.gz
rust-3e264ba13ac0e6c819101d3979ddb7d243cbf0dd.zip
Auto merge of #11881 - y21:issue11880, r=Alexendoo
[`implied_bounds_in_impls`]: avoid linting on overlapping associated tys

Fixes #11880

Before this change, we were simply ignoring associated types (except for suggestion purposes), because of an incorrect assumption (see the comment that I also removed).

For something like
```rs
trait X { type T; }
trait Y: X { type T; }

// Can't constrain `X::T` through `Y`
fn f() -> impl X<T = i32> + Y<T = u32> { ... }
```
We now avoid linting if the implied bound (`X<T = i32>`) "names" associated types that also exists in the implying trait (`trait Y`). Here that would be the case.
But if we only wrote `impl X + Y<T = u32>` then that's ok because `X::T` was never constrained in the first place.

I haven't really thought about how this interacts with GATs, but I think it's fine. Fine as in, it might create false negatives, but hopefully no false positives.

(The diff is slightly annoying because of formatting things. Really the only thing that changed in the if chain is extracting the `implied_by_def_id` which is needed for getting associated types from the trait, and of course actually checking for overlap)

cc `@Jarcho` ? idk if you want to review this or not. I assume you looked into this code a bit to find this bug.

changelog: [`implied_bounds_in_impls`]: avoid linting when associated type from supertrait can't be constrained through the implying trait bound
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions