diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-07-05 08:21:25 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-07-13 04:49:32 +0000 |
| commit | 759b8a8e7dbe4e9ada9f33847ab8d698ee020165 (patch) | |
| tree | 333dc9fc06e32c5eeeffda655327c53fbd55113f /src/libsyntax/parse/parser.rs | |
| parent | 52d485fe0d11d18c51c8868872d472f07b8e06d2 (diff) | |
| download | rust-759b8a8e7dbe4e9ada9f33847ab8d698ee020165.tar.gz rust-759b8a8e7dbe4e9ada9f33847ab8d698ee020165.zip | |
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.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b2cbe252344..454320337ed 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4066,7 +4066,8 @@ impl<'a> Parser<'a> { /// (or the lack thereof) -- c.f. `parse_stmt`. pub fn finish_parsing_statement(&mut self, mut stmt: Stmt) -> PResult<'a, Stmt> { if let StmtKind::Mac(mac) = stmt.node { - if mac.1 != MacStmtStyle::NoBraces || self.token == token::Semi { + if mac.1 != MacStmtStyle::NoBraces || + self.token == token::Semi || self.token == token::Eof { stmt.node = StmtKind::Mac(mac); } else { let (mac, _style, attrs) = mac.unwrap(); |
