File tree Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -663,6 +663,33 @@ trait UnusedDelimLint {
663
663
}
664
664
665
665
// Check if LHS needs parens to prevent false-positives in cases like `fn x() -> u8 { ({ 0 } + 1) }`.
666
+ //
667
+ // FIXME: https://github.com/rust-lang/rust/issues/119426
668
+ // The syntax tree in this code is from after macro expansion, so the
669
+ // current implementation has both false negatives and false positives
670
+ // related to expressions containing macros.
671
+ //
672
+ // macro_rules! m1 {
673
+ // () => {
674
+ // 1
675
+ // };
676
+ // }
677
+ //
678
+ // fn f1() -> u8 {
679
+ // // Lint says parens are not needed, but they are.
680
+ // (m1! {} + 1)
681
+ // }
682
+ //
683
+ // macro_rules! m2 {
684
+ // () => {
685
+ // loop { break 1; }
686
+ // };
687
+ // }
688
+ //
689
+ // fn f2() -> u8 {
690
+ // // Lint says parens are needed, but they are not.
691
+ // (m2!() + 1)
692
+ // }
666
693
{
667
694
let mut innermost = inner;
668
695
loop {
@@ -674,10 +701,7 @@ trait UnusedDelimLint {
674
701
ExprKind :: Index ( base, _subscript, _) => base,
675
702
_ => break ,
676
703
} ;
677
- if match innermost. kind {
678
- ExprKind :: MacCall ( _) => false ,
679
- _ => !classify:: expr_requires_semi_to_be_stmt ( innermost) ,
680
- } {
704
+ if !classify:: expr_requires_semi_to_be_stmt ( innermost) {
681
705
return true ;
682
706
}
683
707
}
You can’t perform that action at this time.
0 commit comments