@@ -30,8 +30,11 @@ pub(crate) fn orphan_check_impl(
30
30
Ok ( ( ) ) => { }
31
31
Err ( err) => match orphan_check ( tcx, impl_def_id, OrphanCheckMode :: Compat ) {
32
32
Ok ( ( ) ) => match err {
33
- OrphanCheckErr :: UncoveredTyParams ( uncovered_ty_params) => {
34
- lint_uncovered_ty_params ( tcx, uncovered_ty_params, impl_def_id)
33
+ OrphanCheckErr :: UncoveredTyParams ( err) => {
34
+ let hir_id = tcx. local_def_id_to_hir_id ( impl_def_id) ;
35
+ complain_about_uncovered_ty_params ! ( tcx, err, |span, diag| {
36
+ tcx. emit_node_span_lint( UNCOVERED_PARAM_IN_PROJECTION , hir_id, span, diag)
37
+ } ) ;
35
38
}
36
39
OrphanCheckErr :: NonLocalInputType ( _) => {
37
40
bug ! ( "orphanck: shouldn't've gotten non-local input tys in compat mode" )
@@ -461,62 +464,33 @@ fn emit_orphan_check_error<'tcx>(
461
464
462
465
diag. emit ( )
463
466
}
464
- traits:: OrphanCheckErr :: UncoveredTyParams ( UncoveredTyParams { uncovered, local_ty } ) => {
465
- let mut reported = None ;
466
- for param_def_id in uncovered {
467
- let span = tcx. def_ident_span ( param_def_id) . unwrap ( ) ;
468
- let name = tcx. item_name ( param_def_id) ;
469
-
470
- reported. get_or_insert ( match local_ty {
471
- Some ( local_type) => tcx
472
- . dcx ( )
473
- . create_err ( errors:: TyParamFirstLocal {
474
- label : span,
475
- note : ( ) ,
476
- param : name,
477
- local_type,
478
- } )
479
- . with_span ( span)
480
- . emit ( ) ,
481
- None => tcx
482
- . dcx ( )
483
- . create_err ( errors:: TyParamSome { label : span, note : ( ) , param : name } )
484
- . with_span ( span)
485
- . emit ( ) ,
486
- } ) ;
487
- }
488
- reported. unwrap ( ) // FIXME(fmease): This is very likely reachable.
467
+ traits:: OrphanCheckErr :: UncoveredTyParams ( err) => {
468
+ complain_about_uncovered_ty_params ! ( tcx, err, |span, diag| tcx
469
+ . dcx( )
470
+ . create_err( diag)
471
+ . with_span( span)
472
+ . emit( ) )
489
473
}
490
474
}
491
475
}
492
476
493
- fn lint_uncovered_ty_params < ' tcx > (
494
- tcx : TyCtxt < ' tcx > ,
495
- UncoveredTyParams { uncovered, local_ty } : UncoveredTyParams < TyCtxt < ' tcx > , FxIndexSet < DefId > > ,
496
- impl_def_id : LocalDefId ,
497
- ) {
498
- let hir_id = tcx. local_def_id_to_hir_id ( impl_def_id) ;
499
-
500
- for param_def_id in uncovered {
501
- let span = tcx. def_ident_span ( param_def_id) . unwrap ( ) ;
502
- let name = tcx. item_name ( param_def_id) ;
503
-
504
- match local_ty {
505
- Some ( local_type) => tcx. emit_node_span_lint (
506
- UNCOVERED_PARAM_IN_PROJECTION ,
507
- hir_id,
508
- span,
509
- errors:: TyParamFirstLocal { label : span, note : ( ) , param : name, local_type } ,
510
- ) ,
511
- None => tcx. emit_node_span_lint (
512
- UNCOVERED_PARAM_IN_PROJECTION ,
513
- hir_id,
514
- span,
515
- errors:: TyParamSome { label : span, note : ( ) , param : name } ,
516
- ) ,
517
- } ;
477
+ macro complain_about_uncovered_ty_params ( $tcx: ident, $err: ident, $emit: expr) { {
478
+ let mut guar = None ;
479
+ for param_def_id in $err. uncovered {
480
+ let span = $tcx. def_ident_span ( param_def_id) . unwrap ( ) ;
481
+ let name = $tcx. item_name ( param_def_id) ;
482
+ guar = Some ( match $err. local_ty {
483
+ Some ( local_type) => $emit( span, errors:: TyParamFirstLocal {
484
+ label : span,
485
+ note : ( ) ,
486
+ param : name,
487
+ local_type,
488
+ } ) ,
489
+ None => $emit( span, errors:: TyParamSome { label : span, note : ( ) , param : name } ) ,
490
+ } ) ;
518
491
}
519
- }
492
+ guar. unwrap ( ) // FIXME(fmease): This very likely reachable
493
+ } }
520
494
521
495
struct UncoveredTyParamCollector < ' cx , ' tcx > {
522
496
infcx : & ' cx InferCtxt < ' tcx > ,
0 commit comments