Skip to content

Replacing match branch with nothing via a macro causes unhelpful diagnostic #36716

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

Closed
ctz opened this issue Sep 25, 2016 · 2 comments
Closed

Comments

@ctz
Copy link
Contributor

ctz commented Sep 25, 2016

Sample code:

macro_rules! warn (
    ($($tt:tt)*) => ()
);

fn main() {
    match 5 {
        5 => warn!("foo"),
        _ => (),
    };
}

Experienced behaviour: this causes this diagnostic and no other output:

error: expected expression, found `<eof>`

Expected behaviour: diagnostic with line/column information pointing to warn! expansion site. For example, if I manually expand the macro the diagnostic is:

error: expected expression, found `,`
 --> <anon>:7:14
  |>
7 |>         5 => ,
  |>              ^

error: aborting due to 2 previous errors

Version:

$ rustc --version --verbose
rustc 1.11.0 (9b21dcd6a 2016-08-15)
binary: rustc
commit-hash: 9b21dcd6a89f38e8ceccb2ede8c9027cb409f6e3
commit-date: 2016-08-15
host: x86_64-unknown-linux-gnu
release: 1.11.0
@TimNN
Copy link
Contributor

TimNN commented Sep 25, 2016

Duplicate of #30128.

@bluss
Copy link
Member

bluss commented Sep 25, 2016

Thank you, closed as dup.

@bluss bluss closed this as completed Sep 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants