Skip to content

Commit

Permalink
Rollup merge of rust-lang#105315 - fmease:norm-subst-iat, r=compiler-…
Browse files Browse the repository at this point in the history
…errors

Normalize inherent associated types after substitution

Fixes rust-lang#105314.

r? ````@cjgillot```` (rust-lang#105224)
````@rustbot```` label F-inherent_associated_types
  • Loading branch information
Yuki Okushi authored Dec 6, 2022
2 parents eeb1bbc + d5cb5fb commit 7ba37ad
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/test/ui/associated-inherent-types/normalize-projection-0.rs
Original file line number Diff line number Diff line change
@@ -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();
}
22 changes: 22 additions & 0 deletions src/test/ui/associated-inherent-types/normalize-projection-1.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 7ba37ad

Please sign in to comment.