diff --git a/chalk-solve/src/rust_ir.rs b/chalk-solve/src/rust_ir.rs index dcb6fbae9bb..ea6514f91eb 100644 --- a/chalk-solve/src/rust_ir.rs +++ b/chalk-solve/src/rust_ir.rs @@ -442,10 +442,11 @@ impl AliasEqBound { let substitution = Substitution::from_iter( interner, - self.parameters - .iter() + trait_ref + .substitution + .iter(interner) .cloned() - .chain(trait_ref.substitution.iter(interner).cloned()), + .chain(self.parameters.iter().cloned()), ); vec![ diff --git a/tests/test/projection.rs b/tests/test/projection.rs index 6dc3a9f2fbf..795ef2494ab 100644 --- a/tests/test/projection.rs +++ b/tests/test/projection.rs @@ -633,6 +633,33 @@ fn gat_in_alias_in_alias_eq() { } } +#[test] +fn gat_bound_for_self_type() { + test! { + program { + struct I32 { } + trait Trait { + type Assoc: Another = usize>; + } + trait Another { + type Gat; + } + } + + goal { + forall { + exists { + if (T: Trait) { + <::Assoc as Another>::Gat = U + } + } + } + } yields[SolverChoice::recursive_default()] { + expect![[r#"Unique; substitution [?0 := Uint(Usize)]"#]] + } + } +} + #[test] fn forall_projection() { test! {