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 · Fixed by #55292
Closed

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

huonw opened this issue Dec 13, 2013 · 5 comments · Fixed by #55292
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-syntaxext Area: Syntax extensions C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority

Comments

@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
Copy link
Contributor

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
Copy link

This is still happening

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

@brson
Copy link
Contributor

brson commented Apr 11, 2017

Still happening.

@brson brson added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) P-low Low priority I-wrong labels Apr 11, 2017
@brson
Copy link
Contributor

brson commented Apr 11, 2017

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

@jseyfried
Copy link
Contributor

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

@Mark-Simulacrum Mark-Simulacrum added C-enhancement Category: An issue proposing an enhancement or a PR with one. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. I-wrong labels Jul 20, 2017
kennytm added a commit to kennytm/rust that referenced this issue Oct 26, 2018
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
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.
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 30, 2023
new lint [`single_call_fn`]

Closes rust-lang#10861

changelog: New lint [`single_call_fn`]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-syntaxext Area: Syntax extensions C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants