@@ -484,19 +484,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
484
484
-> DiagnosticBuilder < ' tcx >
485
485
{
486
486
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) ;
491
490
492
491
if let Some ( trait_item_span) = self . tcx . hir . span_if_local ( trait_item_def_id) {
493
492
let span = self . tcx . sess . codemap ( ) . def_span ( trait_item_span) ;
494
493
err. span_label ( span, format ! ( "definition of `{}` from trait" , item_name) ) ;
495
494
}
496
495
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) ) ;
500
497
501
498
err
502
499
}
@@ -647,7 +644,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
647
644
648
645
ty:: Predicate :: ClosureKind ( closure_def_id, closure_substs, kind) => {
649
646
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 ( ) ) ;
651
649
let node_id = self . tcx . hir . as_local_node_id ( closure_def_id) . unwrap ( ) ;
652
650
let mut err = struct_span_err ! (
653
651
self . tcx. sess, closure_span, E0525 ,
@@ -656,6 +654,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
656
654
kind,
657
655
found_kind) ;
658
656
657
+ err. span_label (
658
+ closure_span,
659
+ format ! ( "this closure implements `{}`, not `{}`" , found_kind, kind) ) ;
659
660
err. span_label (
660
661
obligation. cause . span ,
661
662
format ! ( "the requirement to implement `{}` derives from here" , kind) ) ;
@@ -667,12 +668,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
667
668
let closure_hir_id = self . tcx . hir . node_to_hir_id ( node_id) ;
668
669
match ( found_kind, tables. closure_kind_origins ( ) . get ( closure_hir_id) ) {
669
670
( ty:: ClosureKind :: FnOnce , Some ( ( span, name) ) ) => {
670
- err. span_note ( * span, & format ! (
671
+ err. span_label ( * span, format ! (
671
672
"closure is `FnOnce` because it moves the \
672
673
variable `{}` out of its environment", name) ) ;
673
674
} ,
674
675
( ty:: ClosureKind :: FnMut , Some ( ( span, name) ) ) => {
675
- err. span_note ( * span, & format ! (
676
+ err. span_label ( * span, format ! (
676
677
"closure is `FnMut` because it mutates the \
677
678
variable `{}` here", name) ) ;
678
679
} ,
0 commit comments