diff options
| author | León Orell Valerian Liehr <liehr.exchange@gmx.net> | 2022-12-05 18:02:47 +0100 |
|---|---|---|
| committer | León Orell Valerian Liehr <liehr.exchange@gmx.net> | 2022-12-05 18:02:47 +0100 |
| commit | d5cb5fb1853952c0e5377e86a09c0fcf5bf2a829 (patch) | |
| tree | 160d882892d85b29a6d2d6d938d782c8d212552c | |
| parent | 203c8765ea33c65d888febe0e8219c4bb11b0d89 (diff) | |
| download | rust-d5cb5fb1853952c0e5377e86a09c0fcf5bf2a829.tar.gz rust-d5cb5fb1853952c0e5377e86a09c0fcf5bf2a829.zip | |
normalize inherent associated types after substitution
3 files changed, 45 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index f204d59d005..66906b331da 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -1930,6 +1930,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { adt_substs, ); let ty = tcx.bound_type_of(assoc_ty_did).subst(tcx, item_substs); + let ty = self.normalize_ty(span, ty); return Ok((ty, DefKind::AssocTy, assoc_ty_did)); } } diff --git a/src/test/ui/associated-inherent-types/normalize-projection-0.rs b/src/test/ui/associated-inherent-types/normalize-projection-0.rs new file mode 100644 index 00000000000..50763ecddf9 --- /dev/null +++ b/src/test/ui/associated-inherent-types/normalize-projection-0.rs @@ -0,0 +1,22 @@ +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct S<T>(T); + +impl<T: O> S<T> { + type P = <T as O>::P; +} + +trait O { + type P; +} + +impl O for i32 { + type P = String; +} + +fn main() { + let _: S<i32>::P = String::new(); +} diff --git a/src/test/ui/associated-inherent-types/normalize-projection-1.rs b/src/test/ui/associated-inherent-types/normalize-projection-1.rs new file mode 100644 index 00000000000..2f7b2551a03 --- /dev/null +++ b/src/test/ui/associated-inherent-types/normalize-projection-1.rs @@ -0,0 +1,22 @@ +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct S; + +impl S { + type P<T: O> = <T as O>::P; +} + +trait O { + type P; +} + +impl O for i32 { + type P = String; +} + +fn main() { + let _: S::P<i32> = String::new(); +} |
