@@ -173,13 +173,11 @@ fn compare_predicate_entailment<'tcx>(
173
173
impl_to_placeholder_substs. rebase_onto ( tcx, impl_m. container_id ( tcx) , trait_to_impl_substs) ;
174
174
debug ! ( "compare_impl_method: trait_to_placeholder_substs={:?}" , trait_to_placeholder_substs) ;
175
175
176
- let impl_m_generics = tcx. generics_of ( impl_m. def_id ) ;
177
- let trait_m_generics = tcx. generics_of ( trait_m. def_id ) ;
178
176
let impl_m_predicates = tcx. predicates_of ( impl_m. def_id ) ;
179
177
let trait_m_predicates = tcx. predicates_of ( trait_m. def_id ) ;
180
178
181
179
// Check region bounds.
182
- check_region_bounds_on_impl_item ( tcx, impl_m, trait_m, & trait_m_generics , & impl_m_generics ) ?;
180
+ check_region_bounds_on_impl_item ( tcx, impl_m, trait_m, false ) ?;
183
181
184
182
// Create obligations for each predicate declared by the impl
185
183
// definition in the context of the trait's parameter
@@ -338,6 +336,7 @@ pub fn collect_trait_impl_trait_tys<'tcx>(
338
336
// First, check a few of the same thing as `compare_impl_method`, just so we don't ICE during substitutions later.
339
337
compare_number_of_generics ( tcx, impl_m, trait_m, tcx. hir ( ) . span_if_local ( impl_m. def_id ) , true ) ?;
340
338
compare_generic_param_kinds ( tcx, impl_m, trait_m, true ) ?;
339
+ check_region_bounds_on_impl_item ( tcx, impl_m, trait_m, true ) ?;
341
340
342
341
let trait_to_impl_substs = impl_trait_ref. substs ;
343
342
@@ -722,12 +721,14 @@ fn check_region_bounds_on_impl_item<'tcx>(
722
721
tcx : TyCtxt < ' tcx > ,
723
722
impl_m : & ty:: AssocItem ,
724
723
trait_m : & ty:: AssocItem ,
725
- trait_generics : & ty:: Generics ,
726
- impl_generics : & ty:: Generics ,
724
+ delay : bool ,
727
725
) -> Result < ( ) , ErrorGuaranteed > {
728
- let trait_params = trait_generics . own_counts ( ) . lifetimes ;
726
+ let impl_generics = tcx . generics_of ( impl_m . def_id ) ;
729
727
let impl_params = impl_generics. own_counts ( ) . lifetimes ;
730
728
729
+ let trait_generics = tcx. generics_of ( trait_m. def_id ) ;
730
+ let trait_params = trait_generics. own_counts ( ) . lifetimes ;
731
+
731
732
debug ! (
732
733
"check_region_bounds_on_impl_item: \
733
734
trait_generics={:?} \
@@ -761,12 +762,16 @@ fn check_region_bounds_on_impl_item<'tcx>(
761
762
None
762
763
} ;
763
764
764
- let reported = tcx. sess . emit_err ( LifetimesOrBoundsMismatchOnTrait {
765
- span,
766
- item_kind : assoc_item_kind_str ( impl_m) ,
767
- ident : impl_m. ident ( tcx) ,
768
- generics_span,
769
- } ) ;
765
+ let reported = tcx
766
+ . sess
767
+ . create_err ( LifetimesOrBoundsMismatchOnTrait {
768
+ span,
769
+ item_kind : assoc_item_kind_str ( impl_m) ,
770
+ ident : impl_m. ident ( tcx) ,
771
+ generics_span,
772
+ } )
773
+ . emit_unless ( delay) ;
774
+
770
775
return Err ( reported) ;
771
776
}
772
777
@@ -1504,18 +1509,10 @@ fn compare_type_predicate_entailment<'tcx>(
1504
1509
let trait_to_impl_substs =
1505
1510
impl_substs. rebase_onto ( tcx, impl_ty. container_id ( tcx) , impl_trait_ref. substs ) ;
1506
1511
1507
- let impl_ty_generics = tcx. generics_of ( impl_ty. def_id ) ;
1508
- let trait_ty_generics = tcx. generics_of ( trait_ty. def_id ) ;
1509
1512
let impl_ty_predicates = tcx. predicates_of ( impl_ty. def_id ) ;
1510
1513
let trait_ty_predicates = tcx. predicates_of ( trait_ty. def_id ) ;
1511
1514
1512
- check_region_bounds_on_impl_item (
1513
- tcx,
1514
- impl_ty,
1515
- trait_ty,
1516
- & trait_ty_generics,
1517
- & impl_ty_generics,
1518
- ) ?;
1515
+ check_region_bounds_on_impl_item ( tcx, impl_ty, trait_ty, false ) ?;
1519
1516
1520
1517
let impl_ty_own_bounds = impl_ty_predicates. instantiate_own ( tcx, impl_substs) ;
1521
1518
0 commit comments