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

Is the "Macros in the AST" section still up to date? #19

Open
gnzlbg opened this issue Feb 12, 2017 · 3 comments
Open

Is the "Macros in the AST" section still up to date? #19

gnzlbg opened this issue Feb 12, 2017 · 3 comments

Comments

@gnzlbg
Copy link

gnzlbg commented Feb 12, 2017

The macros in the AST section says:

The first two are "attributes", and are shared between both language-specific constructs (such as #[repr(C)] which is used to request a C-compatible ABI for user-defined types) and syntax extensions (such as #[derive(Clone)]). There is currently no way to define a macro that uses these forms.

(emphasis mine)

But a custom-derive macro can use these forms, right? (otherwise sorry for the noise).

@Redrield
Copy link

Doesn't seem up to date. Seems like a vestige of the days before user defined proc macros were possible.

@ropottnik
Copy link

I think this is outdated too, right?

As previously mentioned, macro processing in Rust happens after the construction of the AST. As such, the syntax used to invoke a macro must be a proper part of the language's syntax.

Also imo it is contradicted by this paragraph below:

Disregarding all but the third form ($name ! $arg), the question becomes: how does the Rust parser know what $arg looks like for every possible syntax extension? The answer is that it doesn't have to. Instead, the argument of a syntax extension invocation is a single token tree.

To me it seems, the chapter would be more accurate if these two sentences above were removed completely. Should I make a PR?

@bjorn3
Copy link

bjorn3 commented Oct 5, 2020

Macro processing does happen after construction of the AST. There is just a special AST node for macro calls that contains a token tree.

No changes have been merged for five years now.

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

4 participants