@@ -606,32 +606,30 @@ fn span_from_macro_expansion_has_safety_comment(cx: &LateContext<'_>, span: Span
606
606
let ctxt = span. ctxt ( ) ;
607
607
if ctxt == SyntaxContext :: root ( ) {
608
608
HasSafetyComment :: Maybe
609
- } else {
610
- // From a macro expansion. Get the text from the start of the macro declaration to start of the
611
- // unsafe block.
609
+ } else if let Ok ( unsafe_line ) = source_map . lookup_line ( span . lo ( ) )
610
+ // From a macro expansion. Get the text from the start of the macro declaration to start of
611
+ // the unsafe block.
612
612
// macro_rules! foo { () => { stuff }; (x) => { unsafe { stuff } }; }
613
613
// ^--------------------------------------------^
614
- if let Ok ( unsafe_line) = source_map. lookup_line ( span. lo ( ) )
615
- && let Ok ( macro_line) = source_map. lookup_line ( ctxt. outer_expn_data ( ) . def_site . lo ( ) )
616
- && Arc :: ptr_eq ( & unsafe_line. sf , & macro_line. sf )
617
- && let Some ( src) = unsafe_line. sf . src . as_deref ( )
618
- {
619
- if macro_line. line < unsafe_line. line {
620
- match text_has_safety_comment (
621
- src,
622
- & unsafe_line. sf . lines ( ) [ macro_line. line + 1 ..=unsafe_line. line ] ,
623
- unsafe_line. sf . start_pos ,
624
- ) {
625
- Some ( b) => HasSafetyComment :: Yes ( b) ,
626
- None => HasSafetyComment :: No ,
627
- }
628
- } else {
629
- HasSafetyComment :: No
614
+ && let Ok ( macro_line) = source_map. lookup_line ( ctxt. outer_expn_data ( ) . def_site . lo ( ) )
615
+ && Arc :: ptr_eq ( & unsafe_line. sf , & macro_line. sf )
616
+ && let Some ( src) = unsafe_line. sf . src . as_deref ( )
617
+ {
618
+ if macro_line. line < unsafe_line. line {
619
+ match text_has_safety_comment (
620
+ src,
621
+ & unsafe_line. sf . lines ( ) [ macro_line. line + 1 ..=unsafe_line. line ] ,
622
+ unsafe_line. sf . start_pos ,
623
+ ) {
624
+ Some ( b) => HasSafetyComment :: Yes ( b) ,
625
+ None => HasSafetyComment :: No ,
630
626
}
631
627
} else {
632
- // Problem getting source text. Pretend a comment was found.
633
- HasSafetyComment :: Maybe
628
+ HasSafetyComment :: No
634
629
}
630
+ } else {
631
+ // Problem getting source text. Pretend a comment was found.
632
+ HasSafetyComment :: Maybe
635
633
}
636
634
}
637
635
0 commit comments