From da8eb29a2f70a58122903bf087bd6c1d0fbd6d3f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 3 Apr 2020 15:38:42 +0200 Subject: Macro patterns are not confused with expressions. We treat macro calls as expressions (there's appropriate Into impl), which causes problem if there's expresison and non-expression macro in the same node (like in the match arm). We fix this problem by nesting macor patterns into another node (the same way we nest path into PathExpr or PathPat). Ideally, we probably should add a similar nesting for macro expressions, but that needs some careful thinking about macros in blocks: `{ am_i_expression!() }`. --- xtask/src/ast_src.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'xtask/src') diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 99bd60198..d9f51ec39 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -138,6 +138,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "SLICE_PAT", "RANGE_PAT", "LITERAL_PAT", + "MACRO_PAT", // atoms "TUPLE_EXPR", "ARRAY_EXPR", @@ -440,6 +441,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { struct SlicePat { args: [Pat] } struct RangePat {} struct LiteralPat { Literal } + struct MacroPat { MacroCall } struct RecordPat { RecordFieldPatList, Path } struct RecordFieldPatList { @@ -622,6 +624,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { SlicePat, RangePat, LiteralPat, + MacroPat, } enum AttrInput { Literal, TokenTree } -- cgit v1.2.3