@@ -76,7 +76,7 @@ impl EarlyLintPass for WhileTrue {
7676 if let ast:: LitKind :: Bool ( true ) = lit. kind {
7777 if !lit. span . from_expansion ( ) {
7878 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 ) ;
8080 cx. struct_span_lint ( WHILE_TRUE , condition_span, |lint| {
8181 lint. build ( msg)
8282 . span_suggestion_short (
@@ -374,9 +374,13 @@ impl MissingDoc {
374374
375375 let has_doc = attrs. iter ( ) . any ( |a| has_doc ( a) ) ;
376376 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+ ) ;
380384 }
381385 }
382386}
@@ -406,7 +410,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
406410 if !has_doc {
407411 cx. struct_span_lint (
408412 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 ) ,
410414 |lint| lint. build ( "missing documentation for macro" ) . emit ( ) ,
411415 ) ;
412416 }
@@ -978,7 +982,7 @@ impl UnreachablePub {
978982 if span. from_expansion ( ) {
979983 applicability = Applicability :: MaybeIncorrect ;
980984 }
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) ;
982986 cx. struct_span_lint ( UNREACHABLE_PUB , def_span, |lint| {
983987 let mut err = lint. build ( & format ! ( "unreachable `pub` {}" , what) ) ;
984988 let replacement = if cx. tcx . features ( ) . crate_visibility_modifier {
0 commit comments