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 @@ -675,6 +675,33 @@ trait UnusedDelimLint {
675
675
}
676
676
677
677
// Check if LHS needs parens to prevent false-positives in cases like `fn x() -> u8 { ({ 0 } + 1) }`.
678
+ //
679
+ // FIXME: https://github.com/rust-lang/rust/issues/119426
680
+ // The syntax tree in this code is from after macro expansion, so the
681
+ // current implementation has both false negatives and false positives
682
+ // related to expressions containing macros.
683
+ //
684
+ // macro_rules! m1 {
685
+ // () => {
686
+ // 1
687
+ // };
688
+ // }
689
+ //
690
+ // fn f1() -> u8 {
691
+ // // Lint says parens are not needed, but they are.
692
+ // (m1! {} + 1)
693
+ // }
694
+ //
695
+ // macro_rules! m2 {
696
+ // () => {
697
+ // loop { break 1; }
698
+ // };
699
+ // }
700
+ //
701
+ // fn f2() -> u8 {
702
+ // // Lint says parens are needed, but they are not.
703
+ // (m2!() + 1)
704
+ // }
678
705
{
679
706
let mut innermost = inner;
680
707
loop {
@@ -686,10 +713,7 @@ trait UnusedDelimLint {
686
713
ExprKind :: Index ( base, _subscript, _) => base,
687
714
_ => break ,
688
715
} ;
689
- if match innermost. kind {
690
- ExprKind :: MacCall ( _) => false ,
691
- _ => !classify:: expr_requires_semi_to_be_stmt ( innermost) ,
692
- } {
716
+ if !classify:: expr_requires_semi_to_be_stmt ( innermost) {
693
717
return true ;
694
718
}
695
719
}
You can’t perform that action at this time.
0 commit comments