Skip to content

Commit 759b8a8

Browse files
committed
Allow macro-expanded macros in trailing expression positions to expand into statements:
```rust macro_rules! m { () => { let x = 1; x } } macro_rules! n { () => { m!() //< This can now expand into statements }} fn main() { n!(); } ``` and revert needless fallout fixes.
1 parent 52d485f commit 759b8a8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4066,7 +4066,8 @@ impl<'a> Parser<'a> {
40664066
/// (or the lack thereof) -- c.f. `parse_stmt`.
40674067
pub fn finish_parsing_statement(&mut self, mut stmt: Stmt) -> PResult<'a, Stmt> {
40684068
if let StmtKind::Mac(mac) = stmt.node {
4069-
if mac.1 != MacStmtStyle::NoBraces || self.token == token::Semi {
4069+
if mac.1 != MacStmtStyle::NoBraces ||
4070+
self.token == token::Semi || self.token == token::Eof {
40704071
stmt.node = StmtKind::Mac(mac);
40714072
} else {
40724073
let (mac, _style, attrs) = mac.unwrap();

src/test/run-pass/simd-intrinsic-generic-cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn main() {
113113
// product macro
114114
($from: ident $(, $from_: ident)*: $($to: ident),*) => {
115115
fn $from() { unsafe { $( test!($from, $to); )* } }
116-
tests!($($from_),*: $($to),*);
116+
tests!($($from_),*: $($to),*)
117117
};
118118
($($types: ident),*) => {{
119119
tests!($($types),* : $($types),*);

0 commit comments

Comments
 (0)