@@ -120,10 +120,7 @@ impl<'tcx> PredicateSearcher<'tcx> {
120120 let initial_self_pred = initial_self_pred ( tcx, owner_id) ;
121121 let mut out = Self {
122122 elab_ctx,
123- typing_env : TypingEnv {
124- param_env : tcx. param_env ( owner_id) ,
125- typing_mode : TypingMode :: PostAnalysis ,
126- } ,
123+ typing_env : TypingEnv :: new ( tcx. param_env ( owner_id) , TypingMode :: PostAnalysis ) ,
127124 candidates : Default :: default ( ) ,
128125 implicit_self_clause : initial_self_pred. is_some ( ) ,
129126 item_refs_cache : Default :: default ( ) ,
@@ -219,25 +216,32 @@ impl<'tcx> PredicateSearcher<'tcx> {
219216 let elab_ctx = self . elab_ctx ;
220217 let tcx = self . elab_ctx . tcx ;
221218 // Note: We skip a binder but rebind it just after.
222- let TyKind :: Alias ( AliasTyKind :: Projection , alias_ty) = ty. skip_binder ( ) . kind ( ) else {
219+ let TyKind :: Alias (
220+ alias @ ty:: AliasTy {
221+ kind : AliasTyKind :: Projection { def_id, .. } ,
222+ args,
223+ ..
224+ } ,
225+ ) = ty. skip_binder ( ) . kind ( )
226+ else {
223227 return ;
224228 } ;
225- let trait_ref = ty. rebind ( alias_ty . trait_ref ( tcx) ) . upcast ( tcx) ;
229+ let trait_ref = ty. rebind ( alias . trait_ref ( tcx) ) . upcast ( tcx) ;
226230
227231 // The predicate we're looking for is is `<T as Trait>::Type: OtherTrait`. We try to solve
228232 // `T as Trait` and add all the bounds on `Trait::Type` to our context.
229233 let proof = self . resolve ( & trait_ref) ;
230234 if matches ! ( proof. kind, TraitProofKind :: Error ( _) ) {
231235 return ;
232236 }
233- let item_ref = self . resolve_item_reference ( alias_ty . def_id , alias_ty . args , true ) ;
237+ let item_ref = self . resolve_item_reference ( * def_id, args, true ) ;
234238
235239 // The bounds that hold on the associated type.
236- let item_bounds = ItemPredicates :: implied ( self . elab_ctx , alias_ty . def_id ) ;
240+ let item_bounds = ItemPredicates :: implied ( self . elab_ctx , * def_id) ;
237241 let item_bounds = item_bounds
238242 . iter_trait_clauses ( )
239243 // Substitute the item generics
240- . map ( |( _, tref) | EarlyBinder :: bind ( tref) . instantiate ( tcx, alias_ty . args ) )
244+ . map ( |( _, tref) | EarlyBinder :: bind ( tref) . instantiate ( tcx, args) )
241245 . enumerate ( ) ;
242246
243247 // Add all the bounds on the corresponding associated item.
@@ -345,8 +349,8 @@ impl<'tcx> PredicateSearcher<'tcx> {
345349 let ty =
346350 Ty :: new_projection ( tcx, assoc. def_id , erased_tref. skip_binder ( ) . args ) ;
347351 let ty = crate :: erase_and_norm ( tcx, self . typing_env , ty) ;
348- if let TyKind :: Alias ( _ , alias_ty) = ty. kind ( )
349- && alias_ty. def_id == assoc. def_id
352+ if let TyKind :: Alias ( alias_ty) = ty. kind ( )
353+ && alias_ty. kind . def_id ( ) == assoc. def_id
350354 {
351355 // Couldn't normalize the type to anything different than itself;
352356 // this must be a built-in associated type such as
0 commit comments