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

MBE template parsing fails with /// #7423

Open
lnicola opened this issue Jan 25, 2021 · 5 comments
Open

MBE template parsing fails with /// #7423

lnicola opened this issue Jan 25, 2021 · 5 comments
Labels
A-macro macro expansion S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@lnicola
Copy link
Member

lnicola commented Jan 25, 2021

macro_rules! features {
        {
            $(
                $name:ident {
                    ///
                }
            ),+
            ,
        } => {};
        {} => {}
}

features! {
    NEON { },
}

fn main() {}

Adapted from ring.

@lnicola lnicola added A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now labels Jan 25, 2021
@lnicola lnicola changed the title MBE expansion fails with /// MBE template parsing fails with /// Jan 25, 2021
@edwin0cheng
Copy link
Member

edwin0cheng commented Jan 25, 2021

This part in rustc is quite ambitious :

This one works:

macro_rules! m{
    {{
       #[doc=r"abcde"]
    }
    } => { }
}
m!({/**abcde*/});
fn main() {}

This one doesn't works:

macro_rules! m{
    {{
       /**abcde*/
    }
    } => { }
}

m!({/**abcde*/});
fn main() {}

This one works:

macro_rules! m{
    {{
       /***/
    }
    } => { }
}

m!({/***/});
fn main() {}

This one doesn't work:

macro_rules! m{
    {{
       ///
    }
    } => { }
}

m!({
    ///
});

fn main() {}

(ノಠ益ಠ)ノ彡┻━┻

@lnicola lnicola added S-unactionable Issue requires feedback, design decisions or is blocked on other work and removed S-actionable Someone could pick this issue up and work on it right now labels Jan 25, 2021
@lnicola
Copy link
Member Author

lnicola commented Jan 25, 2021

Might be worth asking in #t-compiler.

@lnicola
Copy link
Member Author

lnicola commented Jan 25, 2021

I didn't realize that features! {} actually works with my updated example.

And we also seem to expose the #[doc] desugaring:

image

@edwin0cheng
Copy link
Member

I didn't realize that features! {} actually works with my updated example.

The second branch couldn't be matched because of the "NEON" and the comma.

And we also seem to expose the #[doc] desugaring:

Yes, we desugar all doc comment in mbe included empty one, and that's why we failed because we expect a doc comment in macro invocation.

@bjorn3
Copy link
Member

bjorn3 commented Jan 25, 2021

This one doesn't work:
macro_rules! m{
    {{
       ///
    }
    } => { }
}

m!({
    ///
});

fn main() {}

I did guess that rustc doesn't desugar /// into #[doc = "..."] inside the macro rules matcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests

3 participants