@@ -507,20 +507,18 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> HasSaf
507
507
&& Lrc :: ptr_eq ( & unsafe_line. sf , & comment_start_line. sf )
508
508
&& let Some ( src) = unsafe_line. sf . src . as_deref ( )
509
509
{
510
- return unsafe_line. sf . lines ( |lines| {
511
- if comment_start_line. line >= unsafe_line. line {
512
- HasSafetyComment :: No
513
- } else {
514
- match text_has_safety_comment (
515
- src,
516
- & lines[ comment_start_line. line + 1 ..=unsafe_line. line ] ,
517
- unsafe_line. sf . start_pos ,
518
- ) {
519
- Some ( b) => HasSafetyComment :: Yes ( b) ,
520
- None => HasSafetyComment :: No ,
521
- }
510
+ return if comment_start_line. line >= unsafe_line. line {
511
+ HasSafetyComment :: No
512
+ } else {
513
+ match text_has_safety_comment (
514
+ src,
515
+ & unsafe_line. sf . lines ( ) [ comment_start_line. line + 1 ..=unsafe_line. line ] ,
516
+ unsafe_line. sf . start_pos ,
517
+ ) {
518
+ Some ( b) => HasSafetyComment :: Yes ( b) ,
519
+ None => HasSafetyComment :: No ,
522
520
}
523
- } ) ;
521
+ } ;
524
522
}
525
523
}
526
524
HasSafetyComment :: Maybe
@@ -551,20 +549,18 @@ fn stmt_has_safety_comment(cx: &LateContext<'_>, span: Span, hir_id: HirId) -> H
551
549
&& Lrc :: ptr_eq ( & unsafe_line. sf , & comment_start_line. sf )
552
550
&& let Some ( src) = unsafe_line. sf . src . as_deref ( )
553
551
{
554
- return unsafe_line. sf . lines ( |lines| {
555
- if comment_start_line. line >= unsafe_line. line {
556
- HasSafetyComment :: No
557
- } else {
558
- match text_has_safety_comment (
559
- src,
560
- & lines[ comment_start_line. line + 1 ..=unsafe_line. line ] ,
561
- unsafe_line. sf . start_pos ,
562
- ) {
563
- Some ( b) => HasSafetyComment :: Yes ( b) ,
564
- None => HasSafetyComment :: No ,
565
- }
552
+ return if comment_start_line. line >= unsafe_line. line {
553
+ HasSafetyComment :: No
554
+ } else {
555
+ match text_has_safety_comment (
556
+ src,
557
+ & unsafe_line. sf . lines ( ) [ comment_start_line. line + 1 ..=unsafe_line. line ] ,
558
+ unsafe_line. sf . start_pos ,
559
+ ) {
560
+ Some ( b) => HasSafetyComment :: Yes ( b) ,
561
+ None => HasSafetyComment :: No ,
566
562
}
567
- } ) ;
563
+ } ;
568
564
}
569
565
}
570
566
HasSafetyComment :: Maybe
@@ -614,20 +610,18 @@ fn span_from_macro_expansion_has_safety_comment(cx: &LateContext<'_>, span: Span
614
610
&& Lrc :: ptr_eq ( & unsafe_line. sf , & macro_line. sf )
615
611
&& let Some ( src) = unsafe_line. sf . src . as_deref ( )
616
612
{
617
- unsafe_line. sf . lines ( |lines| {
618
- if macro_line. line < unsafe_line. line {
619
- match text_has_safety_comment (
620
- src,
621
- & 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 ,
626
- }
627
- } else {
628
- HasSafetyComment :: No
613
+ if macro_line. line < unsafe_line. line {
614
+ match text_has_safety_comment (
615
+ src,
616
+ & unsafe_line. sf . lines ( ) [ macro_line. line + 1 ..=unsafe_line. line ] ,
617
+ unsafe_line. sf . start_pos ,
618
+ ) {
619
+ Some ( b) => HasSafetyComment :: Yes ( b) ,
620
+ None => HasSafetyComment :: No ,
629
621
}
630
- } )
622
+ } else {
623
+ HasSafetyComment :: No
624
+ }
631
625
} else {
632
626
// Problem getting source text. Pretend a comment was found.
633
627
HasSafetyComment :: Maybe
@@ -671,13 +665,11 @@ fn span_in_body_has_safety_comment(cx: &LateContext<'_>, span: Span) -> bool {
671
665
// Get the text from the start of function body to the unsafe block.
672
666
// fn foo() { some_stuff; unsafe { stuff }; other_stuff; }
673
667
// ^-------------^
674
- unsafe_line. sf . lines ( |lines| {
675
- body_line. line < unsafe_line. line && text_has_safety_comment (
676
- src,
677
- & lines[ body_line. line + 1 ..=unsafe_line. line ] ,
678
- unsafe_line. sf . start_pos ,
679
- ) . is_some ( )
680
- } )
668
+ body_line. line < unsafe_line. line && text_has_safety_comment (
669
+ src,
670
+ & unsafe_line. sf . lines ( ) [ body_line. line + 1 ..=unsafe_line. line ] ,
671
+ unsafe_line. sf . start_pos ,
672
+ ) . is_some ( )
681
673
} else {
682
674
// Problem getting source text. Pretend a comment was found.
683
675
true
0 commit comments