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

semicolon check in macro needs improving #37217

Closed
bombless opened this issue Oct 16, 2016 · 4 comments
Closed

semicolon check in macro needs improving #37217

bombless opened this issue Oct 16, 2016 · 4 comments

Comments

@bombless
Copy link
Contributor

https://play.rust-lang.org/?gist=9aca9a98b74f8a4522df7b0d16c8340e&version=beta&backtrace=0&run=1

I think the warning message here is not intentional.

@TimNN
Copy link
Contributor

TimNN commented Oct 16, 2016

I'm pretty sure the warning message works as intended:

The first macro invocation (own!(a, b);) expands to own!(@a) own!(@b) which, if written in normal rust code, would produce a hard error. This was previously accepted by the compiler, but now triggers the warning introduced in #34660.

@bombless
Copy link
Contributor Author

Hmm then the warning should be turned into an hard error now, I guess, thanks @TimNN

@bombless
Copy link
Contributor Author

May I ask, why is the semicolon after to_owned() dropped in the (@$x:ident) => { let $x = $x.to_owned(); }; part?
I figure it might be the root case that bug existed, which I don't really understand.

@TimNN
Copy link
Contributor

TimNN commented Oct 16, 2016

I don't think that semicolon is dropped. However, as far as I know, macros are expanded in multiple steps: own!(a, b); is expanded to own!(@a) own!(@b), which then parsed again and expanded to let a = ...; let b = ...; The warning is reported for the intermediate expansion, not the final one: the semicolons added by the (@$x:ident) rule don't exist yet.

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

2 participants