@@ -340,11 +340,7 @@ fn block_has_safety_comment(cx: &LateContext<'_>, span: Span) -> bool {
340
340
// ```
341
341
// won't work. This is to avoid dealing with where such a comment should be place relative to
342
342
// attributes and doc comments.
343
-
344
- matches ! (
345
- span_from_macro_expansion_has_safety_comment( cx, span) ,
346
- HasSafetyComment :: Yes ( _)
347
- ) || span_in_body_has_safety_comment ( cx, span)
343
+ span_in_body_has_safety_comment ( cx, span)
348
344
}
349
345
350
346
enum HasSafetyComment {
@@ -356,11 +352,6 @@ enum HasSafetyComment {
356
352
/// Checks if the lines immediately preceding the item contain a safety comment.
357
353
#[ allow( clippy:: collapsible_match) ]
358
354
fn item_has_safety_comment ( cx : & LateContext < ' _ > , item : & hir:: Item < ' _ > ) -> HasSafetyComment {
359
- match span_from_macro_expansion_has_safety_comment ( cx, item. span ) {
360
- HasSafetyComment :: Maybe => ( ) ,
361
- has_safety_comment => return has_safety_comment,
362
- }
363
-
364
355
if item. span . ctxt ( ) != SyntaxContext :: root ( ) {
365
356
return HasSafetyComment :: No ;
366
357
}
@@ -420,11 +411,6 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> HasSaf
420
411
/// Checks if the lines immediately preceding the item contain a safety comment.
421
412
#[ allow( clippy:: collapsible_match) ]
422
413
fn stmt_has_safety_comment ( cx : & LateContext < ' _ > , span : Span , hir_id : HirId ) -> HasSafetyComment {
423
- match span_from_macro_expansion_has_safety_comment ( cx, span) {
424
- HasSafetyComment :: Maybe => ( ) ,
425
- has_safety_comment => return has_safety_comment,
426
- }
427
-
428
414
if span. ctxt ( ) != SyntaxContext :: root ( ) {
429
415
return HasSafetyComment :: No ;
430
416
}
@@ -490,42 +476,6 @@ fn comment_start_before_item_in_mod(
490
476
} )
491
477
}
492
478
493
- fn span_from_macro_expansion_has_safety_comment ( cx : & LateContext < ' _ > , span : Span ) -> HasSafetyComment {
494
- let source_map = cx. sess ( ) . source_map ( ) ;
495
- let ctxt = span. ctxt ( ) ;
496
- if ctxt == SyntaxContext :: root ( ) {
497
- HasSafetyComment :: Maybe
498
- } else {
499
- // From a macro expansion. Get the text from the start of the macro declaration to start of the
500
- // unsafe block.
501
- // macro_rules! foo { () => { stuff }; (x) => { unsafe { stuff } }; }
502
- // ^--------------------------------------------^
503
- if let Ok ( unsafe_line) = source_map. lookup_line ( span. lo ( ) )
504
- && let Ok ( macro_line) = source_map. lookup_line ( ctxt. outer_expn_data ( ) . def_site . lo ( ) )
505
- && Lrc :: ptr_eq ( & unsafe_line. sf , & macro_line. sf )
506
- && let Some ( src) = unsafe_line. sf . src . as_deref ( )
507
- {
508
- unsafe_line. sf . lines ( |lines| {
509
- if macro_line. line < unsafe_line. line {
510
- match text_has_safety_comment (
511
- src,
512
- & lines[ macro_line. line + 1 ..=unsafe_line. line ] ,
513
- unsafe_line. sf . start_pos . to_usize ( ) ,
514
- ) {
515
- Some ( b) => HasSafetyComment :: Yes ( b) ,
516
- None => HasSafetyComment :: No ,
517
- }
518
- } else {
519
- HasSafetyComment :: No
520
- }
521
- } )
522
- } else {
523
- // Problem getting source text. Pretend a comment was found.
524
- HasSafetyComment :: Maybe
525
- }
526
- }
527
- }
528
-
529
479
fn get_body_search_span ( cx : & LateContext < ' _ > ) -> Option < Span > {
530
480
let body = cx. enclosing_body ?;
531
481
let map = cx. tcx . hir ( ) ;
0 commit comments