@@ -130,22 +130,22 @@ impl<I: Interner> ToProgramClauses<I> for OpaqueTyDatum<I> {
130130 /// ```
131131 /// where `!T<..>` is the placeholder for the unnormalized type `T<..>`.
132132 fn to_program_clauses ( & self , builder : & mut ClauseBuilder < ' _ , I > ) {
133- let interner = builder. interner ( ) ;
134- let substitution = builder. substitution_in_scope ( ) ;
135- let alias = AliasTy :: Opaque ( OpaqueTy {
136- opaque_ty_id : self . opaque_ty_id ,
137- substitution : substitution. clone ( ) ,
138- } ) ;
133+ builder. push_binders ( & self . bound , |builder, opaque_ty_bound| {
134+ let interner = builder. interner ( ) ;
135+ let substitution = builder. substitution_in_scope ( ) ;
136+ let alias = AliasTy :: Opaque ( OpaqueTy {
137+ opaque_ty_id : self . opaque_ty_id ,
138+ substitution : substitution. clone ( ) ,
139+ } ) ;
139140
140- let alias_ty = Ty :: new (
141- interner,
142- ApplicationTy {
143- name : TypeName :: OpaqueType ( self . opaque_ty_id ) ,
144- substitution,
145- } ,
146- ) ;
141+ let alias_placeholder_ty = Ty :: new (
142+ interner,
143+ ApplicationTy {
144+ name : TypeName :: OpaqueType ( self . opaque_ty_id ) ,
145+ substitution,
146+ } ,
147+ ) ;
147148
148- builder. push_binders ( & self . bound , |builder, opaque_ty_bound| {
149149 // AliasEq(T<..> = HiddenTy) :- Reveal.
150150 builder. push_clause (
151151 DomainGoal :: Holds (
@@ -162,17 +162,19 @@ impl<I: Interner> ToProgramClauses<I> for OpaqueTyDatum<I> {
162162 builder. push_fact ( DomainGoal :: Holds (
163163 AliasEq {
164164 alias : alias. clone ( ) ,
165- ty : alias_ty . clone ( ) ,
165+ ty : alias_placeholder_ty . clone ( ) ,
166166 }
167167 . cast ( interner) ,
168168 ) ) ;
169169
170170 for bound in & opaque_ty_bound. bounds {
171171 // Implemented(!T<..>: Bound).
172- builder. push_binders ( & bound, |builder, bound| {
173- builder. push_binders ( & bound, |builder, bound| {
174- builder. push_fact ( bound. into_well_formed_goal ( interner) ) ;
175- } ) ;
172+ let bound_with_placeholder_ty = bound. substitute (
173+ interner,
174+ & Substitution :: from1 ( interner, alias_placeholder_ty. clone ( ) ) ,
175+ ) ;
176+ builder. push_binders ( & bound_with_placeholder_ty, |builder, bound| {
177+ builder. push_fact ( bound. into_well_formed_goal ( interner) ) ;
176178 } ) ;
177179 }
178180
@@ -181,7 +183,7 @@ impl<I: Interner> ToProgramClauses<I> for OpaqueTyDatum<I> {
181183 builder. push_clause (
182184 TraitRef {
183185 trait_id : auto_trait_id,
184- substitution : Substitution :: from1 ( interner, alias_ty . clone ( ) ) ,
186+ substitution : Substitution :: from1 ( interner, alias_placeholder_ty . clone ( ) ) ,
185187 } ,
186188 iter:: once ( TraitRef {
187189 trait_id : auto_trait_id,
0 commit comments