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

Support declarative macros 2.0 #2248

Closed
edwin0cheng opened this issue Nov 15, 2019 · 9 comments
Closed

Support declarative macros 2.0 #2248

edwin0cheng opened this issue Nov 15, 2019 · 9 comments
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@edwin0cheng
Copy link
Member

edwin0cheng commented Nov 15, 2019

Some source code in rustc start to using decl-macro :

https://github.com/rust-lang/rust/blob/82cf3a4486bc882207a09bf0d9e2dea4632781aa/src/libsyntax_ext/lib.rs#L52-L60

It would be nice to support it (at least in parser) or ignore it right now to have a better experince on browsing rustc source code by RA.

@DJMcNab
Copy link
Contributor

DJMcNab commented Nov 19, 2019

We also need this for e.g. https://doc.rust-lang.org/std/clone/macro.Clone.html to get proper doc comments for derive macros.

@edwin0cheng
Copy link
Member Author

In ra_parser, should we add a new ast::MacroCall2 or reuse ast::MacroCall and let hir decided which one to be ?

@DJMcNab
Copy link
Contributor

DJMcNab commented Nov 20, 2019

I don't think we should reuse macro call

@matklad
Copy link
Member

matklad commented Nov 20, 2019

For macro keyword, calls and defs have different syntax, so we should just add a dedicated node for this, MacroDef

@DJMcNab
Copy link
Contributor

DJMcNab commented Nov 20, 2019

Hold on though - in #2315 I'm already using MacroDef to mean macro_rules or procedural macros. We either need a different name for that or a different name for this

@matklad
Copy link
Member

matklad commented Nov 20, 2019 via email

@DJMcNab
Copy link
Contributor

DJMcNab commented Nov 20, 2019

I needed to do that because a lot of stuff used e.g. the NameOwner impl of MacroDefId.ast_id, and MacroDef needed to implement from and To source, which needed a Syntax node implementor to cast it from and to

@edwin0cheng edwin0cheng added the A-macro macro expansion label Mar 3, 2020
bors bot added a commit that referenced this issue Dec 16, 2020
6897: Basic support for macros 2.0 r=jonas-schievink a=jonas-schievink

This adds support for (built-in-only) macros 2.0, and removes some hacks used for builtin derives, which are declared via macros 2.0 in libcore.

First steps for #2248.

Blocked on rust-analyzer/ungrammar#16.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Jan 25, 2021
@jonas-schievink
Copy link
Contributor

FYI: Rust 1.51.0 will stabilize core::ptr::{addr_of, addr_of_mut}, which are "2.0" macros

@edwin0cheng
Copy link
Member Author

Since #8212 was merged. Let's close it first and handle related problems (Macro hygiene in macro 2.0) in separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

5 participants