@@ -49,11 +49,11 @@ pub(crate) fn compare_impl_method<'tcx>(
49
49
return ;
50
50
}
51
51
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 ) {
53
53
return ;
54
54
}
55
55
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 ) {
57
57
return ;
58
58
}
59
59
@@ -349,8 +349,8 @@ pub fn collect_trait_impl_trait_tys<'tcx>(
349
349
let param_env = tcx. param_env ( def_id) ;
350
350
351
351
// 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 ) ?;
354
354
355
355
let trait_to_impl_substs = impl_trait_ref. substs ;
356
356
@@ -927,6 +927,7 @@ fn compare_number_of_generics<'tcx>(
927
927
impl_ : & ty:: AssocItem ,
928
928
trait_ : & ty:: AssocItem ,
929
929
trait_span : Option < Span > ,
930
+ delay : bool ,
930
931
) -> Result < ( ) , ErrorGuaranteed > {
931
932
let trait_own_counts = tcx. generics_of ( trait_. def_id ) . own_counts ( ) ;
932
933
let impl_own_counts = tcx. generics_of ( impl_. def_id ) . own_counts ( ) ;
@@ -1056,7 +1057,7 @@ fn compare_number_of_generics<'tcx>(
1056
1057
err. span_label ( * span, "`impl Trait` introduces an implicit type parameter" ) ;
1057
1058
}
1058
1059
1059
- let reported = err. emit ( ) ;
1060
+ let reported = err. emit_unless ( delay ) ;
1060
1061
err_occurred = Some ( reported) ;
1061
1062
}
1062
1063
}
@@ -1308,6 +1309,7 @@ fn compare_generic_param_kinds<'tcx>(
1308
1309
tcx : TyCtxt < ' tcx > ,
1309
1310
impl_item : & ty:: AssocItem ,
1310
1311
trait_item : & ty:: AssocItem ,
1312
+ delay : bool ,
1311
1313
) -> Result < ( ) , ErrorGuaranteed > {
1312
1314
assert_eq ! ( impl_item. kind, trait_item. kind) ;
1313
1315
@@ -1365,7 +1367,7 @@ fn compare_generic_param_kinds<'tcx>(
1365
1367
err. span_label ( impl_header_span, "" ) ;
1366
1368
err. span_label ( param_impl_span, make_param_message ( "found" , param_impl) ) ;
1367
1369
1368
- let reported = err. emit ( ) ;
1370
+ let reported = err. emit_unless ( delay ) ;
1369
1371
return Err ( reported) ;
1370
1372
}
1371
1373
}
@@ -1491,9 +1493,9 @@ pub(crate) fn compare_ty_impl<'tcx>(
1491
1493
debug ! ( "compare_impl_type(impl_trait_ref={:?})" , impl_trait_ref) ;
1492
1494
1493
1495
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 ) ?;
1495
1497
1496
- compare_generic_param_kinds ( tcx, impl_ty, trait_ty) ?;
1498
+ compare_generic_param_kinds ( tcx, impl_ty, trait_ty, false ) ?;
1497
1499
1498
1500
let sp = tcx. def_span ( impl_ty. def_id ) ;
1499
1501
compare_type_predicate_entailment ( tcx, impl_ty, sp, trait_ty, impl_trait_ref) ?;
0 commit comments