@@ -116,8 +116,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
116
116
117
117
let impl_assoc_identity_args = ty:: GenericArgs :: identity_for_item ( tcx, def_id) ;
118
118
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 ;
121
120
122
121
let impl_assoc_args =
123
122
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
158
157
match item. kind {
159
158
ItemKind :: Impl ( impl_) => {
160
159
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 ( ) ) ) ;
164
162
}
165
163
}
166
164
ItemKind :: Trait ( _, _, _, _, _, self_bounds, ..)
@@ -350,9 +348,10 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
350
348
// before uses of `U`. This avoids false ambiguity errors
351
349
// in trait checking. See `setup_constraining_predicates`
352
350
// for details.
353
- if let Node :: Item ( & Item { kind : ItemKind :: Impl { .. } , .. } ) = node {
351
+ if let Node :: Item ( & Item { kind : ItemKind :: Impl ( impl_ ) , .. } ) = node {
354
352
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 ( ) ) ;
356
355
cgp:: setup_constraining_predicates (
357
356
tcx,
358
357
& mut predicates,
@@ -460,11 +459,12 @@ fn const_evaluatable_predicates_of<'tcx>(
460
459
}
461
460
462
461
if let hir:: Node :: Item ( item) = node
463
- && let hir:: ItemKind :: Impl ( _ ) = item. kind
462
+ && let hir:: ItemKind :: Impl ( impl_ ) = item. kind
464
463
{
465
- if let Some ( of_trait) = tcx . impl_trait_ref ( def_id ) {
464
+ if impl_ . of_trait . is_some ( ) {
466
465
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) ;
468
468
}
469
469
470
470
debug ! ( "visit self_ty" ) ;
0 commit comments