@@ -484,19 +484,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
484484 -> DiagnosticBuilder < ' tcx >
485485 {
486486 let msg = "impl has stricter requirements than trait" ;
487- let mut err = struct_span_err ! ( self . tcx. sess,
488- error_span,
489- E0276 ,
490- "{}" , msg) ;
487+ let sp = self . tcx . sess . codemap ( ) . def_span ( error_span) ;
488+
489+ let mut err = struct_span_err ! ( self . tcx. sess, sp, E0276 , "{}" , msg) ;
491490
492491 if let Some ( trait_item_span) = self . tcx . hir . span_if_local ( trait_item_def_id) {
493492 let span = self . tcx . sess . codemap ( ) . def_span ( trait_item_span) ;
494493 err. span_label ( span, format ! ( "definition of `{}` from trait" , item_name) ) ;
495494 }
496495
497- err. span_label (
498- error_span,
499- format ! ( "impl has extra requirement {}" , requirement) ) ;
496+ err. span_label ( sp, format ! ( "impl has extra requirement {}" , requirement) ) ;
500497
501498 err
502499 }
@@ -647,7 +644,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
647644
648645 ty:: Predicate :: ClosureKind ( closure_def_id, closure_substs, kind) => {
649646 let found_kind = self . closure_kind ( closure_def_id, closure_substs) . unwrap ( ) ;
650- let closure_span = self . tcx . hir . span_if_local ( closure_def_id) . unwrap ( ) ;
647+ let closure_span = self . tcx . sess . codemap ( )
648+ . def_span ( self . tcx . hir . span_if_local ( closure_def_id) . unwrap ( ) ) ;
651649 let node_id = self . tcx . hir . as_local_node_id ( closure_def_id) . unwrap ( ) ;
652650 let mut err = struct_span_err ! (
653651 self . tcx. sess, closure_span, E0525 ,
@@ -656,6 +654,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
656654 kind,
657655 found_kind) ;
658656
657+ err. span_label (
658+ closure_span,
659+ format ! ( "this closure implements `{}`, not `{}`" , found_kind, kind) ) ;
659660 err. span_label (
660661 obligation. cause . span ,
661662 format ! ( "the requirement to implement `{}` derives from here" , kind) ) ;
@@ -667,12 +668,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
667668 let closure_hir_id = self . tcx . hir . node_to_hir_id ( node_id) ;
668669 match ( found_kind, tables. closure_kind_origins ( ) . get ( closure_hir_id) ) {
669670 ( ty:: ClosureKind :: FnOnce , Some ( ( span, name) ) ) => {
670- err. span_note ( * span, & format ! (
671+ err. span_label ( * span, format ! (
671672 "closure is `FnOnce` because it moves the \
672673 variable `{}` out of its environment", name) ) ;
673674 } ,
674675 ( ty:: ClosureKind :: FnMut , Some ( ( span, name) ) ) => {
675- err. span_note ( * span, & format ! (
676+ err. span_label ( * span, format ! (
676677 "closure is `FnMut` because it mutates the \
677678 variable `{}` here", name) ) ;
678679 } ,
0 commit comments