@@ -1470,45 +1470,22 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1470
1470
1471
1471
// The method kind does not correspond to what appeared in the trait, report.
1472
1472
let path = & self . current_trait_ref . as_ref ( ) . unwrap ( ) . 1 . path ;
1473
- let path = & path_names_to_string ( path) ;
1474
- let mut err = match kind {
1475
- AssocItemKind :: Const ( ..) => {
1476
- rustc_errors:: struct_span_err!(
1477
- self . r. session,
1478
- span,
1479
- E0323 ,
1480
- "item `{}` is an associated const, which doesn't match its trait `{}`" ,
1481
- ident,
1482
- path,
1483
- )
1484
- }
1485
- AssocItemKind :: Fn ( ..) => {
1486
- rustc_errors:: struct_span_err!(
1487
- self . r. session,
1488
- span,
1489
- E0324 ,
1490
- "item `{}` is an associated method, which doesn't match its trait `{}`" ,
1491
- ident,
1492
- path,
1493
- )
1494
- }
1495
- AssocItemKind :: TyAlias ( ..) => {
1496
- rustc_errors:: struct_span_err!(
1497
- self . r. session,
1498
- span,
1499
- E0325 ,
1500
- "item `{}` is an associated type, which doesn't match its trait `{}`" ,
1501
- ident,
1502
- path,
1503
- )
1504
- }
1505
- AssocItemKind :: MacCall ( ..) => {
1506
- span_bug ! ( span, "macros should have been expanded" )
1507
- }
1473
+ let ( code, kind) = match kind {
1474
+ AssocItemKind :: Const ( ..) => ( rustc_errors:: error_code!( E0323 ) , "const" ) ,
1475
+ AssocItemKind :: Fn ( ..) => ( rustc_errors:: error_code!( E0324 ) , "method" ) ,
1476
+ AssocItemKind :: TyAlias ( ..) => ( rustc_errors:: error_code!( E0325 ) , "type" ) ,
1477
+ AssocItemKind :: MacCall ( ..) => span_bug ! ( span, "unexpanded macro" ) ,
1508
1478
} ;
1509
- err. span_label ( span, "does not match trait" ) ;
1510
- err. span_label ( binding. span , "item in trait" ) ;
1511
- err. emit ( ) ;
1479
+ self . report_error (
1480
+ span,
1481
+ ResolutionError :: TraitImplMismatch {
1482
+ name : ident. name ,
1483
+ kind,
1484
+ code,
1485
+ trait_path : path_names_to_string ( path) ,
1486
+ trait_item_span : binding. span ,
1487
+ } ,
1488
+ ) ;
1512
1489
}
1513
1490
1514
1491
fn resolve_params ( & mut self , params : & ' ast [ Param ] ) {
0 commit comments