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_rules! definitions with parenthesis breaks filtering by item path #101

Closed
ElusiveMori opened this issue Feb 8, 2021 · 3 comments
Closed

Comments

@ElusiveMori
Copy link

ElusiveMori commented Feb 8, 2021

Example:

// lib.rs
pub mod a;

// a.rs
macro_rules! b (
    () => {}
);

Running cargo expand whatever will dump the whole expanded crate.

If we change the macro to

macro_rules! b {
    () => {}
}

It will fail correctly with WARNING: no such item: asdasda

Having a macro like this anywhere in the crate will break the path resolution mechanism, for some reason, causing the path to be ignored all the time.

I'm not sure if macro_rules with parens has any rightful place to exist, but I just spent about half an hour trying to figure this one out ;-;

@ehuss
Copy link
Collaborator

ehuss commented Feb 8, 2021

This appears to be a bug in rustc's expander. It emits the following:

#![feature(prelude_import)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
pub mod a {
    macro_rules! b(() => { })
}

Notice that it strips the semicolon.

@ehuss
Copy link
Collaborator

ehuss commented Feb 8, 2021

Posted rust-lang/rust#81888 with a fix.

@dtolnay
Copy link
Owner

dtolnay commented Feb 10, 2021

Confirmed fixed as of nightly-2021-02-10 by rust-lang/rust#81888.

@dtolnay dtolnay closed this as completed Feb 10, 2021
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