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