rust/compiler/rustc_hir_analysis/src
nils 7e90732abe
Rollup merge of #109470 - compiler-errors:gat-normalize-bound, r=jackh726
Correctly substitute GAT's type used in `normalize_param_env` in `check_type_bounds`

Given:

```rust
trait Foo {
    type Assoc<T>: PartialEq<Self::Assoc<i32>>;
}

impl Foo for () {
    type Assoc<T> = Wrapper<T>;
}

struct Wrapper<T>(T);

impl<T> PartialEq<Wrapper<i32>> for Wrapper<T> { }
```

We add an additional predicate in the `normalize_param_env` in `check_type_bounds` that is used to normalize the GAT's bounds to check them in the impl. Problematically, though, that predicate is constructed to be `for<^0> <() as Foo>::Assoc<^0> => Wrapper<T>`, instead of `for<^0> <() as Foo>::Assoc<^0> => Wrapper<^0>`.

That means `Self::Assoc<i32>` in the bounds that we're checking normalizes to `Wrapper<T>`, instead of `Wrapper<i32>`, and so the bound `Self::Assoc<T>: PartialEq<Self::Assoc<i32>>` normalizes to `Wrapper<T>: PartialEq<Wrapper<T>>`, which does not hold.

Fixes this by properly substituting the RHS of that normalizes predicate that we add to the `normalize_param_env`. That means the bound is properly normalized to `Wrapper<T>: PartialEq<Wrapper<i32>>`, which *does* hold.

---

The second commit in this PR just cleans up some substs stuff and some naming.

r? `@jackh726` cc #87900
2023-03-28 12:51:13 +02:00
..
astconv Don't elaborate non-obligations into obligations 2023-03-26 20:33:54 +00:00
check Rollup merge of #109470 - compiler-errors:gat-normalize-bound, r=jackh726 2023-03-28 12:51:13 +02:00
coherence Auto merge of #109202 - compiler-errors:new-solver-fast-reject-faster-2, r=lcnr 2023-03-23 23:53:56 +00:00
collect Don't elaborate non-obligations into obligations 2023-03-26 20:33:54 +00:00
impl_wf_check Don't elaborate non-obligations into obligations 2023-03-26 20:33:54 +00:00
outlives Rename AliasEq -> AliasRelate 2023-03-23 05:56:40 +00:00
structured_errors migrate rustc_hir_analysis to session diagnostic 2023-03-05 00:01:55 +03:00
variance IdentitySubsts::identity_for_item takes Into<DefId> 2023-03-21 15:38:52 +00:00
autoderef.rs Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
bounds.rs Rework hir Bounds collection 2022-12-28 23:40:09 +00:00
check_unused.rs Remove last instances of HashSet in query result types. 2023-03-01 10:20:45 +01:00
collect.rs HirId to LocalDefId cleanup 2023-03-22 10:36:30 +01:00
constrained_generic_params.rs Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
errors.rs Forbid the use of #[target_feature] on start 2023-03-12 14:57:38 +01:00
hir_wf_check.rs Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errors 2023-03-22 05:33:18 +00:00
impl_wf_check.rs Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
lib.rs Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errors 2023-03-22 05:33:18 +00:00
structured_errors.rs