@@ -76,7 +76,7 @@ impl EarlyLintPass for WhileTrue {
76
76
if let ast:: LitKind :: Bool ( true ) = lit. kind {
77
77
if !lit. span . from_expansion ( ) {
78
78
let msg = "denote infinite loops with `loop { ... }`" ;
79
- let condition_span = cx. sess . source_map ( ) . def_span ( e. span ) ;
79
+ let condition_span = cx. sess . source_map ( ) . guess_head_span ( e. span ) ;
80
80
cx. struct_span_lint ( WHILE_TRUE , condition_span, |lint| {
81
81
lint. build ( msg)
82
82
. span_suggestion_short (
@@ -374,9 +374,13 @@ impl MissingDoc {
374
374
375
375
let has_doc = attrs. iter ( ) . any ( |a| has_doc ( a) ) ;
376
376
if !has_doc {
377
- cx. struct_span_lint ( MISSING_DOCS , cx. tcx . sess . source_map ( ) . def_span ( sp) , |lint| {
378
- lint. build ( & format ! ( "missing documentation for {} {}" , article, desc) ) . emit ( )
379
- } ) ;
377
+ cx. struct_span_lint (
378
+ MISSING_DOCS ,
379
+ cx. tcx . sess . source_map ( ) . guess_head_span ( sp) ,
380
+ |lint| {
381
+ lint. build ( & format ! ( "missing documentation for {} {}" , article, desc) ) . emit ( )
382
+ } ,
383
+ ) ;
380
384
}
381
385
}
382
386
}
@@ -406,7 +410,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
406
410
if !has_doc {
407
411
cx. struct_span_lint (
408
412
MISSING_DOCS ,
409
- cx. tcx . sess . source_map ( ) . def_span ( macro_def. span ) ,
413
+ cx. tcx . sess . source_map ( ) . guess_head_span ( macro_def. span ) ,
410
414
|lint| lint. build ( "missing documentation for macro" ) . emit ( ) ,
411
415
) ;
412
416
}
@@ -978,7 +982,7 @@ impl UnreachablePub {
978
982
if span. from_expansion ( ) {
979
983
applicability = Applicability :: MaybeIncorrect ;
980
984
}
981
- let def_span = cx. tcx . sess . source_map ( ) . def_span ( span) ;
985
+ let def_span = cx. tcx . sess . source_map ( ) . guess_head_span ( span) ;
982
986
cx. struct_span_lint ( UNREACHABLE_PUB , def_span, |lint| {
983
987
let mut err = lint. build ( & format ! ( "unreachable `pub` {}" , what) ) ;
984
988
let replacement = if cx. tcx . features ( ) . crate_visibility_modifier {
0 commit comments