@@ -173,13 +173,11 @@ fn compare_predicate_entailment<'tcx>(
173173 impl_to_placeholder_substs. rebase_onto ( tcx, impl_m. container_id ( tcx) , trait_to_impl_substs) ;
174174 debug ! ( "compare_impl_method: trait_to_placeholder_substs={:?}" , trait_to_placeholder_substs) ;
175175
176- let impl_m_generics = tcx. generics_of ( impl_m. def_id ) ;
177- let trait_m_generics = tcx. generics_of ( trait_m. def_id ) ;
178176 let impl_m_predicates = tcx. predicates_of ( impl_m. def_id ) ;
179177 let trait_m_predicates = tcx. predicates_of ( trait_m. def_id ) ;
180178
181179 // 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 ) ?;
183181
184182 // Create obligations for each predicate declared by the impl
185183 // definition in the context of the trait's parameter
@@ -338,6 +336,7 @@ pub fn collect_trait_impl_trait_tys<'tcx>(
338336 // First, check a few of the same thing as `compare_impl_method`, just so we don't ICE during substitutions later.
339337 compare_number_of_generics ( tcx, impl_m, trait_m, tcx. hir ( ) . span_if_local ( impl_m. def_id ) , true ) ?;
340338 compare_generic_param_kinds ( tcx, impl_m, trait_m, true ) ?;
339+ check_region_bounds_on_impl_item ( tcx, impl_m, trait_m, true ) ?;
341340
342341 let trait_to_impl_substs = impl_trait_ref. substs ;
343342
@@ -722,12 +721,14 @@ fn check_region_bounds_on_impl_item<'tcx>(
722721 tcx : TyCtxt < ' tcx > ,
723722 impl_m : & ty:: AssocItem ,
724723 trait_m : & ty:: AssocItem ,
725- trait_generics : & ty:: Generics ,
726- impl_generics : & ty:: Generics ,
724+ delay : bool ,
727725) -> Result < ( ) , ErrorGuaranteed > {
728- let trait_params = trait_generics . own_counts ( ) . lifetimes ;
726+ let impl_generics = tcx . generics_of ( impl_m . def_id ) ;
729727 let impl_params = impl_generics. own_counts ( ) . lifetimes ;
730728
729+ let trait_generics = tcx. generics_of ( trait_m. def_id ) ;
730+ let trait_params = trait_generics. own_counts ( ) . lifetimes ;
731+
731732 debug ! (
732733 "check_region_bounds_on_impl_item: \
733734 trait_generics={:?} \
@@ -761,12 +762,16 @@ fn check_region_bounds_on_impl_item<'tcx>(
761762 None
762763 } ;
763764
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+
770775 return Err ( reported) ;
771776 }
772777
@@ -1504,18 +1509,10 @@ fn compare_type_predicate_entailment<'tcx>(
15041509 let trait_to_impl_substs =
15051510 impl_substs. rebase_onto ( tcx, impl_ty. container_id ( tcx) , impl_trait_ref. substs ) ;
15061511
1507- let impl_ty_generics = tcx. generics_of ( impl_ty. def_id ) ;
1508- let trait_ty_generics = tcx. generics_of ( trait_ty. def_id ) ;
15091512 let impl_ty_predicates = tcx. predicates_of ( impl_ty. def_id ) ;
15101513 let trait_ty_predicates = tcx. predicates_of ( trait_ty. def_id ) ;
15111514
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 ) ?;
15191516
15201517 let impl_ty_own_bounds = impl_ty_predicates. instantiate_own ( tcx, impl_substs) ;
15211518
0 commit comments