Is the "Macros in the AST" section still up to date?
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).
Doesn't seem up to date. Seems like a vestige of the days before user defined proc macros were possible.
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$arglooks 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?
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.