@@ -49,11 +49,11 @@ pub(crate) fn compare_impl_method<'tcx>(
4949 return ;
5050 }
5151
52- if let Err ( _) = compare_number_of_generics ( tcx, impl_m, trait_m, trait_item_span) {
52+ if let Err ( _) = compare_number_of_generics ( tcx, impl_m, trait_m, trait_item_span, false ) {
5353 return ;
5454 }
5555
56- if let Err ( _) = compare_generic_param_kinds ( tcx, impl_m, trait_m) {
56+ if let Err ( _) = compare_generic_param_kinds ( tcx, impl_m, trait_m, false ) {
5757 return ;
5858 }
5959
@@ -349,8 +349,8 @@ pub fn collect_trait_impl_trait_tys<'tcx>(
349349 let param_env = tcx. param_env ( def_id) ;
350350
351351 // First, check a few of the same thing as `compare_impl_method`, just so we don't ICE during substitutions later.
352- compare_number_of_generics ( tcx, impl_m, trait_m, tcx. hir ( ) . span_if_local ( impl_m. def_id ) ) ?;
353- compare_generic_param_kinds ( tcx, impl_m, trait_m) ?;
352+ compare_number_of_generics ( tcx, impl_m, trait_m, tcx. hir ( ) . span_if_local ( impl_m. def_id ) , true ) ?;
353+ compare_generic_param_kinds ( tcx, impl_m, trait_m, true ) ?;
354354
355355 let trait_to_impl_substs = impl_trait_ref. substs ;
356356
@@ -927,6 +927,7 @@ fn compare_number_of_generics<'tcx>(
927927 impl_ : & ty:: AssocItem ,
928928 trait_ : & ty:: AssocItem ,
929929 trait_span : Option < Span > ,
930+ delay : bool ,
930931) -> Result < ( ) , ErrorGuaranteed > {
931932 let trait_own_counts = tcx. generics_of ( trait_. def_id ) . own_counts ( ) ;
932933 let impl_own_counts = tcx. generics_of ( impl_. def_id ) . own_counts ( ) ;
@@ -1056,7 +1057,7 @@ fn compare_number_of_generics<'tcx>(
10561057 err. span_label ( * span, "`impl Trait` introduces an implicit type parameter" ) ;
10571058 }
10581059
1059- let reported = err. emit ( ) ;
1060+ let reported = err. emit_unless ( delay ) ;
10601061 err_occurred = Some ( reported) ;
10611062 }
10621063 }
@@ -1308,6 +1309,7 @@ fn compare_generic_param_kinds<'tcx>(
13081309 tcx : TyCtxt < ' tcx > ,
13091310 impl_item : & ty:: AssocItem ,
13101311 trait_item : & ty:: AssocItem ,
1312+ delay : bool ,
13111313) -> Result < ( ) , ErrorGuaranteed > {
13121314 assert_eq ! ( impl_item. kind, trait_item. kind) ;
13131315
@@ -1365,7 +1367,7 @@ fn compare_generic_param_kinds<'tcx>(
13651367 err. span_label ( impl_header_span, "" ) ;
13661368 err. span_label ( param_impl_span, make_param_message ( "found" , param_impl) ) ;
13671369
1368- let reported = err. emit ( ) ;
1370+ let reported = err. emit_unless ( delay ) ;
13691371 return Err ( reported) ;
13701372 }
13711373 }
@@ -1491,9 +1493,9 @@ pub(crate) fn compare_ty_impl<'tcx>(
14911493 debug ! ( "compare_impl_type(impl_trait_ref={:?})" , impl_trait_ref) ;
14921494
14931495 let _: Result < ( ) , ErrorGuaranteed > = ( || {
1494- compare_number_of_generics ( tcx, impl_ty, trait_ty, trait_item_span) ?;
1496+ compare_number_of_generics ( tcx, impl_ty, trait_ty, trait_item_span, false ) ?;
14951497
1496- compare_generic_param_kinds ( tcx, impl_ty, trait_ty) ?;
1498+ compare_generic_param_kinds ( tcx, impl_ty, trait_ty, false ) ?;
14971499
14981500 let sp = tcx. def_span ( impl_ty. def_id ) ;
14991501 compare_type_predicate_entailment ( tcx, impl_ty, sp, trait_ty, impl_trait_ref) ?;
0 commit comments