Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro with empty expansion in expression position causes an "unexpected <eof>" error #10951

Closed
huonw opened this Issue Dec 13, 2013 · 5 comments

Comments

Projects
None yet
6 participants
@huonw
Copy link
Member

huonw commented Dec 13, 2013

macro_rules! foo ( () => () );
fn main() { foo!() }
expand.rs:1:0: 1:0 error: unexpected token: `<eof>`
expand.rs:1 macro_rules! foo ( () => () );
            ^

(Moving the foo!() outside main works.)

@DanielKeep

This comment has been minimized.

Copy link
Contributor

DanielKeep commented Sep 17, 2014

Still happening as of latest nightly:

rustc 0.12.0-pre-nightly (63eaba24d 2014-09-15 21:56:00 +0000)
binary: rustc
commit-hash: 63eaba24d6a7f93061d63337ea1f7083ca892787
commit-date: 2014-09-15 21:56:00 +0000
host: i686-w64-mingw32
release: 0.12.0-pre-nightly
@charlesetc

This comment has been minimized.

Copy link

charlesetc commented Nov 2, 2015

This is still happening

% rustc --version                                                                                                                           
rustc 1.5.0-dev (0be1bcd06 2015-10-24)
@brson

This comment has been minimized.

Copy link
Contributor

brson commented Apr 11, 2017

Still happening.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Apr 11, 2017

@jseyfried just pinging you to make you aware and spark your interest.

@jseyfried

This comment has been minimized.

Copy link
Contributor

jseyfried commented Apr 13, 2017

The issue here is that foo!() is an expression position, so we expect it to be exactly one expression.
If it were foo!(); or foo! { }, then it would be in a statement(s) position and would compile.

This distinction isn't ideal, but I've already cleaned it up about as much as possible given back-compat constraints (see #34660), so I'm not sure there's much we can do about it now.

cc @nrc

kennytm added a commit to kennytm/rust that referenced this issue Oct 26, 2018

Rollup merge of rust-lang#55292 - estebank:macro-eof, r=pnkfelix
Macro diagnostics tweaks

Fix rust-lang#30128, fix rust-lang#10951 by adding an appropriate span to the diagnostic.
Fix rust-lang#26288 by suggesting adding semicolon to macro call.

kennytm added a commit to kennytm/rust that referenced this issue Oct 26, 2018

Rollup merge of rust-lang#55292 - estebank:macro-eof, r=pnkfelix
Macro diagnostics tweaks

Fix rust-lang#30128, fix rust-lang#10951 by adding an appropriate span to the diagnostic.
Fix rust-lang#26288 by suggesting adding semicolon to macro call.

kennytm added a commit to kennytm/rust that referenced this issue Oct 26, 2018

Rollup merge of rust-lang#55292 - estebank:macro-eof, r=pnkfelix
Macro diagnostics tweaks

Fix rust-lang#30128, fix rust-lang#10951 by adding an appropriate span to the diagnostic.
Fix rust-lang#26288 by suggesting adding semicolon to macro call.

@bors bors closed this in #55292 Oct 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.