You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All expansion errors in expression position and type position are treated this way, such as a failure to match rule during macro_rules expansion, a procedural macro panic, or invalid token stream produced by a macro. (Macro failure in pattern position instead appears as _, and in item position the whole item is omitted.)
We should consider whether it would be appropriate for proc-macro2 to capture /*ERROR*/, or (/*ERROR*/), when parsed by our fallback parser. Most likely this would take the form of parsing it into TokenTree::Literal. For the above code snippet, syn would get a syntax tree resembling:
$ rustc -Zunpretty=expanded <(echo 'fn main() { let _ = compile_error!("..."); }')
Stderr:
Stdout:
Notice that an error during macro expansion materializes in the expanded code in the form
(/*ERROR*/)
.This corresponds to
rustc_ast
'sExprKind::Err
. https://github.com/rust-lang/rust/blob/1.72.0/compiler/rustc_ast/src/ast.rs#L1533-L1534All expansion errors in expression position and type position are treated this way, such as a failure to match rule during macro_rules expansion, a procedural macro panic, or invalid token stream produced by a macro. (Macro failure in pattern position instead appears as
_
, and in item position the whole item is omitted.)We should consider whether it would be appropriate for proc-macro2 to capture
/*ERROR*/
, or(/*ERROR*/)
, when parsed by our fallback parser. Most likely this would take the form of parsing it intoTokenTree::Literal
. For the above code snippet, syn would get a syntax tree resembling:The text was updated successfully, but these errors were encountered: