-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Syntactically permit postfix macros to reject them later #78849
Conversation
r? @lcnr (rust_highfive has picked a reviewer for you, use r? to override) |
See https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/documenting.20Rust.20syntax - has this been run by lang team? |
@jyn514 I can't find an FCP for #75857 but #66183 had an FCP, so I guess one is needed. cc @joshtriplett who has authored an RFC about postfix macros. |
cc @ehuss too |
70fd3e9
to
f26578b
Compare
I'll reroute this to the lang team immediately. |
@petrochenkov that RFC won't get merged any time soon, but not because of disagreements on the syntax, but because of disagreement on the semantics. I haven't read a single comment in that thread which disagreed about the proposed invocation syntax. It's basically obvious how it should be.
|
I feel that unlike #75857 this is at least partially an expression of intent, so I do believe it requires at least an FCP |
This improves error messages and enables proc macros to work with the postfix macro syntax.
f26578b
to
2654252
Compare
While I would love to have postfix macros (I proposed RFC 2442 in the first place), I don't think we should parse them if we're not going to accept them. I would love to see RFC 2442 revived. I've just rewritten that RFC to bring it up to date with current Rust. Thank you for working on this, @est31! |
@joshtriplett thanks for the kind words and thanks for reviving the RFC. I hope that this time it gets through, but I'm doubtful, given the contents of the thread. Parsing postfix macros would allow experimentation with attribute macros outside of the main language. |
One more general solution to this problem is to delay parsing of anything inside delimited groups ( This way people will be able to use pretty much any arbitrary syntax (modulo the the requirement on balanced delimiters) under |
@petrochenkov that'd be a great idea IMO. The main reason these syntax extensions are proposed are attribute macros. Most use cases would benefit tremendously from being able to do a lot of things inside delimitered groups. Would help my proposal and also would have helped #66183, but not #75857 as the attr is directly on the module. I'm not sure about formatters, but imo it should be easy for formatters to speculatively treat something as Rust and if it isn't then just bail out somehow. |
@petrochenkov That seems like a great idea for many reasons, not least of which improving handling of conditional compilation so that it works to hide new features from old compilers. |
Closing in favour of a more general approach: #78849 (comment) |
Change the parser to syntactically permit postfix bang macros (
foo.bar!()
) to be parsed by rustc, but still reject them later on before they would be expanded or even resolved.Similar prior work: #75857 and #66183.
The intention of this PR is to allow attribute macros to lower the postfix macro syntax to something of their choosing.
For everyone else, it improves error messages.
becomes