@@ -482,11 +482,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
482
482
483
483
ty:: Predicate :: ClosureKind ( closure_def_id, closure_substs, kind) => {
484
484
let found_kind = self . closure_kind ( closure_substs) . unwrap ( ) ;
485
- let closure_span = self
486
- . tcx
487
- . sess
488
- . source_map ( )
489
- . def_span ( self . tcx . hir ( ) . span_if_local ( closure_def_id) . unwrap ( ) ) ;
485
+ let closure_span =
486
+ self . tcx . sess . source_map ( ) . guess_head_span (
487
+ self . tcx . hir ( ) . span_if_local ( closure_def_id) . unwrap ( ) ,
488
+ ) ;
490
489
let hir_id = self . tcx . hir ( ) . as_local_hir_id ( closure_def_id) . unwrap ( ) ;
491
490
let mut err = struct_span_err ! (
492
491
self . tcx. sess,
@@ -580,7 +579,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
580
579
581
580
let found_span = found_did
582
581
. and_then ( |did| self . tcx . hir ( ) . span_if_local ( did) )
583
- . map ( |sp| self . tcx . sess . source_map ( ) . def_span ( sp) ) ; // the sp could be an fn def
582
+ . map ( |sp| self . tcx . sess . source_map ( ) . guess_head_span ( sp) ) ; // the sp could be an fn def
584
583
585
584
if self . reported_closure_mismatch . borrow ( ) . contains ( & ( span, found_span) ) {
586
585
// We check closures twice, with obligations flowing in different directions,
@@ -680,7 +679,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
680
679
kind : hir:: ExprKind :: Closure ( _, ref _decl, id, span, _) ,
681
680
..
682
681
} ) => (
683
- self . tcx . sess . source_map ( ) . def_span ( span) ,
682
+ self . tcx . sess . source_map ( ) . guess_head_span ( span) ,
684
683
self . tcx
685
684
. hir ( )
686
685
. body ( id)
@@ -723,7 +722,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
723
722
kind : hir:: TraitItemKind :: Fn ( ref sig, _) ,
724
723
..
725
724
} ) => (
726
- self . tcx . sess . source_map ( ) . def_span ( span) ,
725
+ self . tcx . sess . source_map ( ) . guess_head_span ( span) ,
727
726
sig. decl
728
727
. inputs
729
728
. iter ( )
@@ -741,7 +740,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
741
740
. ctor_hir_id ( )
742
741
. map ( |hir_id| self . tcx . hir ( ) . span ( hir_id) )
743
742
. unwrap_or ( DUMMY_SP ) ;
744
- let span = self . tcx . sess . source_map ( ) . def_span ( span) ;
743
+ let span = self . tcx . sess . source_map ( ) . guess_head_span ( span) ;
745
744
746
745
( span, vec ! [ ArgKind :: empty( ) ; variant_data. fields( ) . len( ) ] )
747
746
}
@@ -1624,7 +1623,7 @@ pub fn recursive_type_with_infinite_size_error(
1624
1623
) -> DiagnosticBuilder < ' tcx > {
1625
1624
assert ! ( type_def_id. is_local( ) ) ;
1626
1625
let span = tcx. hir ( ) . span_if_local ( type_def_id) . unwrap ( ) ;
1627
- let span = tcx. sess . source_map ( ) . def_span ( span) ;
1626
+ let span = tcx. sess . source_map ( ) . guess_head_span ( span) ;
1628
1627
let mut err = struct_span_err ! (
1629
1628
tcx. sess,
1630
1629
span,
0 commit comments