forked from rust-lang/rustfmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't insert semicolons inside of a
macro_rules!
arm body
Currently, rustfmt inserts semicolons for certain trailing expressions (`return`, `continue`, and `break`). However, this should not be done in the body of a `macro_rules!` arm, since the macro might be used in expression position (where a trailing semicolon will be invalid). Currently, this rewriting has no effect due to rust-lang/rust#33953 If this issue is fixed, then this rewriting will prevent some macros from being used in expression position. This commit prevents rustfmt from inserting semicolons for trailing expressions in `macro_rules!` arms. The user is free to either include or omit the semicolon - rustfmt will not modify either case.
- Loading branch information
Showing
9 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
macro_rules! expr { | ||
(no_semi) => { | ||
return true | ||
}; | ||
(semi) => { | ||
return true; | ||
}; | ||
} | ||
|
||
fn foo() -> bool { | ||
match true { | ||
true => expr!(no_semi), | ||
false if false => { | ||
expr!(semi) | ||
} | ||
false => { | ||
expr!(semi); | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |