@@ -116,8 +116,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
116116
117117 let impl_assoc_identity_args = ty:: GenericArgs :: identity_for_item ( tcx, def_id) ;
118118 let impl_def_id = tcx. parent ( fn_def_id) ;
119- let impl_trait_ref_args =
120- tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) . instantiate_identity ( ) . args ;
119+ let impl_trait_ref_args = tcx. impl_trait_ref ( impl_def_id) . instantiate_identity ( ) . args ;
121120
122121 let impl_assoc_args =
123122 impl_assoc_identity_args. rebase_onto ( tcx, impl_def_id, impl_trait_ref_args) ;
@@ -158,9 +157,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
158157 match item. kind {
159158 ItemKind :: Impl ( impl_) => {
160159 if impl_. defaultness . is_default ( ) {
161- is_default_impl_trait = tcx
162- . impl_trait_ref ( def_id)
163- . map ( |t| ty:: Binder :: dummy ( t. instantiate_identity ( ) ) ) ;
160+ is_default_impl_trait =
161+ Some ( ty:: Binder :: dummy ( tcx. impl_trait_ref ( def_id) . instantiate_identity ( ) ) ) ;
164162 }
165163 }
166164 ItemKind :: Trait ( _, _, _, _, _, self_bounds, ..)
@@ -350,9 +348,10 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
350348 // before uses of `U`. This avoids false ambiguity errors
351349 // in trait checking. See `setup_constraining_predicates`
352350 // for details.
353- if let Node :: Item ( & Item { kind : ItemKind :: Impl { .. } , .. } ) = node {
351+ if let Node :: Item ( & Item { kind : ItemKind :: Impl ( impl_ ) , .. } ) = node {
354352 let self_ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
355- let trait_ref = tcx. impl_trait_ref ( def_id) . map ( ty:: EarlyBinder :: instantiate_identity) ;
353+ let trait_ref =
354+ impl_. of_trait . is_some ( ) . then ( || tcx. impl_trait_ref ( def_id) . instantiate_identity ( ) ) ;
356355 cgp:: setup_constraining_predicates (
357356 tcx,
358357 & mut predicates,
@@ -460,11 +459,12 @@ fn const_evaluatable_predicates_of<'tcx>(
460459 }
461460
462461 if let hir:: Node :: Item ( item) = node
463- && let hir:: ItemKind :: Impl ( _ ) = item. kind
462+ && let hir:: ItemKind :: Impl ( impl_ ) = item. kind
464463 {
465- if let Some ( of_trait) = tcx . impl_trait_ref ( def_id ) {
464+ if impl_ . of_trait . is_some ( ) {
466465 debug ! ( "visit impl trait_ref" ) ;
467- of_trait. instantiate_identity ( ) . visit_with ( & mut collector) ;
466+ let trait_ref = tcx. impl_trait_ref ( def_id) ;
467+ trait_ref. instantiate_identity ( ) . visit_with ( & mut collector) ;
468468 }
469469
470470 debug ! ( "visit self_ty" ) ;
0 commit comments