From 1d6eef1350ee0793fcd2a0eb191cdb127b76a49d Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 11 Jun 2021 18:12:51 +0200 Subject: Update ungrammar --- Cargo.lock | 4 +- crates/ide/src/hover.rs | 2 +- crates/ide_db/src/defs.rs | 2 +- crates/mbe/src/tests/expand.rs | 42 ++-- crates/parser/src/grammar/attributes.rs | 3 + crates/parser/src/syntax_kind/generated.rs | 2 +- crates/syntax/src/ast/generated/nodes.rs | 31 ++- crates/syntax/src/ast/node_ext.rs | 19 +- .../parser/err/0005_attribute_recover.rast | 66 +++--- .../parser/err/0031_block_inner_attrs.rast | 68 +++--- .../parser/err/0032_match_arms_inner_attrs.rast | 17 +- .../parser/err/0033_match_arms_outer_attrs.rast | 17 +- .../inline/err/0009_attr_on_expr_not_allowed.rast | 18 +- .../parser/inline/ok/0054_record_field_attrs.rast | 25 +- .../parser/inline/ok/0115_tuple_field_attrs.rast | 25 +- .../inline/ok/0118_impl_inner_attributes.rast | 17 +- .../inline/ok/0120_match_arms_inner_attribute.rast | 51 ++-- .../ok/0121_match_arms_outer_attributes.rast | 125 +++++----- .../ok/0122_generic_lifetime_type_attribute.rast | 34 +-- .../ok/0125_record_literal_field_with_attr.rast | 17 +- .../parser/inline/ok/0126_attr_on_expr_stmt.rast | 45 ++-- .../inline/ok/0127_attr_on_last_expr_in_block.rast | 18 +- .../test_data/parser/inline/ok/0130_let_stmt.rast | 9 +- .../inline/ok/0138_self_param_outer_attr.rast | 9 +- .../parser/inline/ok/0139_param_outer_arg.rast | 9 +- .../parser/inline/ok/0145_record_pat_field.rast | 23 +- .../parser/inline/ok/0150_array_attrs.rast | 17 +- .../parser/inline/ok/0152_arg_with_attr.rast | 9 +- .../parser/inline/ok/0154_tuple_attrs.rast | 17 +- .../test_data/parser/ok/0006_inner_attributes.rast | 258 +++++++++++---------- .../syntax/test_data/parser/ok/0008_mod_item.rast | 9 +- .../test_data/parser/ok/0011_outer_attribute.rast | 45 ++-- .../parser/ok/0017_attr_trailing_comma.rast | 19 +- .../test_data/parser/ok/0035_weird_exprs.rast | 87 +++---- .../syntax/test_data/parser/ok/0044_let_attrs.rast | 25 +- .../test_data/parser/ok/0045_block_attrs.rast | 102 ++++---- .../parser/ok/0046_extern_inner_attributes.rast | 17 +- .../test_data/parser/ok/0051_parameter_attrs.rast | 135 ++++++----- .../ok/0053_outer_attribute_on_macro_rules.rast | 9 +- .../syntax/test_data/parser/ok/0062_macro_2.0.rast | 9 +- .../test_data/parser/ok/0063_variadic_fun.rast | 17 +- xtask/Cargo.toml | 2 +- xtask/src/ast_src.rs | 2 +- 43 files changed, 801 insertions(+), 676 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea2c1aed7..12a096ff1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1802,9 +1802,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] name = "ungrammar" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76760314176cc2b94047af2f921b92c39f11a34dc05c43a3c2b0fc91cb22959f" +checksum = "50ef6d7335c77ec3e4a7c4be74c2b9e4642569e94a4004c836f8cca71fede3a7" [[package]] name = "unicase" diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index ed4f18e1f..1c6d36939 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -208,7 +208,7 @@ pub(crate) fn hover( } fn try_hover_for_attribute(token: &SyntaxToken) -> Option> { - let attr = token.ancestors().nth(1).and_then(ast::Attr::cast)?; + let attr = token.ancestors().find_map(ast::Attr::cast)?; let (path, tt) = attr.as_simple_call()?; if !tt.syntax().text_range().contains(token.text_range().start()) { return None; diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs index 1b69d72f9..a54f2c323 100644 --- a/crates/ide_db/src/defs.rs +++ b/crates/ide_db/src/defs.rs @@ -369,7 +369,7 @@ impl NameRefClass { } if let Some(resolved) = sema.resolve_path(&path) { - if path.syntax().parent().and_then(ast::Attr::cast).is_some() { + if path.syntax().ancestors().find_map(ast::Attr::cast).is_some() { if let PathResolution::Def(ModuleDef::Function(func)) = resolved { if func.attrs(sema.db).by_key("proc_macro_attribute").exists() { return Some(NameRefClass::Definition(resolved.into())); diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs index 5f173f513..75c88687c 100644 --- a/crates/mbe/src/tests/expand.rs +++ b/crates/mbe/src/tests/expand.rs @@ -1846,16 +1846,17 @@ fn test_no_space_after_semi_colon() { ATTR@0..21 POUND@0..1 "#" L_BRACK@1..2 "[" - PATH@2..5 - PATH_SEGMENT@2..5 - NAME_REF@2..5 - IDENT@2..5 "cfg" - TOKEN_TREE@5..20 - L_PAREN@5..6 "(" - IDENT@6..13 "feature" - EQ@13..14 "=" - STRING@14..19 "\"std\"" - R_PAREN@19..20 ")" + META@2..20 + PATH@2..5 + PATH_SEGMENT@2..5 + NAME_REF@2..5 + IDENT@2..5 "cfg" + TOKEN_TREE@5..20 + L_PAREN@5..6 "(" + IDENT@6..13 "feature" + EQ@13..14 "=" + STRING@14..19 "\"std\"" + R_PAREN@19..20 ")" R_BRACK@20..21 "]" MOD_KW@21..24 "mod" NAME@24..25 @@ -1865,16 +1866,17 @@ fn test_no_space_after_semi_colon() { ATTR@26..47 POUND@26..27 "#" L_BRACK@27..28 "[" - PATH@28..31 - PATH_SEGMENT@28..31 - NAME_REF@28..31 - IDENT@28..31 "cfg" - TOKEN_TREE@31..46 - L_PAREN@31..32 "(" - IDENT@32..39 "feature" - EQ@39..40 "=" - STRING@40..45 "\"std\"" - R_PAREN@45..46 ")" + META@28..46 + PATH@28..31 + PATH_SEGMENT@28..31 + NAME_REF@28..31 + IDENT@28..31 "cfg" + TOKEN_TREE@31..46 + L_PAREN@31..32 "(" + IDENT@32..39 "feature" + EQ@39..40 "=" + STRING@40..45 "\"std\"" + R_PAREN@45..46 ")" R_BRACK@46..47 "]" MOD_KW@47..50 "mod" NAME@50..51 diff --git a/crates/parser/src/grammar/attributes.rs b/crates/parser/src/grammar/attributes.rs index b8242cd2f..a44c5e484 100644 --- a/crates/parser/src/grammar/attributes.rs +++ b/crates/parser/src/grammar/attributes.rs @@ -13,6 +13,7 @@ pub(super) fn outer_attrs(p: &mut Parser) { } pub(super) fn meta(p: &mut Parser) { + let meta = p.start(); paths::use_path(p); match p.current() { @@ -25,6 +26,8 @@ pub(super) fn meta(p: &mut Parser) { T!['('] | T!['['] | T!['{'] => items::token_tree(p), _ => {} } + + meta.complete(p, META); } fn attr(p: &mut Parser, inner: bool) { diff --git a/crates/parser/src/syntax_kind/generated.rs b/crates/parser/src/syntax_kind/generated.rs index bcefd183a..5f10b82de 100644 --- a/crates/parser/src/syntax_kind/generated.rs +++ b/crates/parser/src/syntax_kind/generated.rs @@ -220,7 +220,7 @@ pub enum SyntaxKind { ITEM_LIST, ASSOC_ITEM_LIST, ATTR, - META_ITEM, + META, USE_TREE, USE_TREE_LIST, PATH, diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs index 9a88fdb56..702de59a9 100644 --- a/crates/syntax/src/ast/generated/nodes.rs +++ b/crates/syntax/src/ast/generated/nodes.rs @@ -150,10 +150,7 @@ impl Attr { pub fn pound_token(&self) -> Option { support::token(&self.syntax, T![#]) } pub fn excl_token(&self) -> Option { support::token(&self.syntax, T![!]) } pub fn l_brack_token(&self) -> Option { support::token(&self.syntax, T!['[']) } - pub fn path(&self) -> Option { support::child(&self.syntax) } - pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } - pub fn expr(&self) -> Option { support::child(&self.syntax) } - pub fn token_tree(&self) -> Option { support::child(&self.syntax) } + pub fn meta(&self) -> Option { support::child(&self.syntax) } pub fn r_brack_token(&self) -> Option { support::token(&self.syntax, T![']']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -632,6 +629,16 @@ impl WherePred { pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Meta { + pub(crate) syntax: SyntaxNode, +} +impl Meta { + pub fn path(&self) -> Option { support::child(&self.syntax) } + pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } + pub fn expr(&self) -> Option { support::child(&self.syntax) } + pub fn token_tree(&self) -> Option { support::child(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ExprStmt { pub(crate) syntax: SyntaxNode, } @@ -2072,6 +2079,17 @@ impl AstNode for WherePred { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for Meta { + fn can_cast(kind: SyntaxKind) -> bool { kind == META } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} impl AstNode for ExprStmt { fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } fn cast(syntax: SyntaxNode) -> Option { @@ -3887,6 +3905,11 @@ impl std::fmt::Display for WherePred { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for Meta { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for ExprStmt { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index a60bc5ad9..3d27d2c1a 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs @@ -144,19 +144,20 @@ impl AttrKind { impl ast::Attr { pub fn as_simple_atom(&self) -> Option { - if self.eq_token().is_some() || self.token_tree().is_some() { + let meta = self.meta()?; + if meta.eq_token().is_some() || meta.token_tree().is_some() { return None; } self.simple_name() } pub fn as_simple_call(&self) -> Option<(SmolStr, ast::TokenTree)> { - let tt = self.token_tree()?; + let tt = self.meta()?.token_tree()?; Some((self.simple_name()?, tt)) } pub fn simple_name(&self) -> Option { - let path = self.path()?; + let path = self.meta()?.path()?; match (path.segment(), path.qualifier()) { (Some(segment), None) => Some(segment.syntax().first_token()?.text().into()), _ => None, @@ -174,6 +175,18 @@ impl ast::Attr { _ => AttrKind::Outer, } } + + pub fn path(&self) -> Option { + self.meta()?.path() + } + + pub fn expr(&self) -> Option { + self.meta()?.expr() + } + + pub fn token_tree(&self) -> Option { + self.meta()?.token_tree() + } } #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/crates/syntax/test_data/parser/err/0005_attribute_recover.rast b/crates/syntax/test_data/parser/err/0005_attribute_recover.rast index 4845a6563..6202c8bfe 100644 --- a/crates/syntax/test_data/parser/err/0005_attribute_recover.rast +++ b/crates/syntax/test_data/parser/err/0005_attribute_recover.rast @@ -3,20 +3,21 @@ SOURCE_FILE@0..54 ATTR@0..18 POUND@0..1 "#" L_BRACK@1..2 "[" - PATH@2..5 - PATH_SEGMENT@2..5 - NAME_REF@2..5 - IDENT@2..5 "foo" - TOKEN_TREE@5..17 - L_PAREN@5..6 "(" - IDENT@6..9 "foo" - COMMA@9..10 "," - WHITESPACE@10..11 " " - PLUS@11..12 "+" - COMMA@12..13 "," - WHITESPACE@13..14 " " - INT_NUMBER@14..16 "92" - R_PAREN@16..17 ")" + META@2..17 + PATH@2..5 + PATH_SEGMENT@2..5 + NAME_REF@2..5 + IDENT@2..5 "foo" + TOKEN_TREE@5..17 + L_PAREN@5..6 "(" + IDENT@6..9 "foo" + COMMA@9..10 "," + WHITESPACE@10..11 " " + PLUS@11..12 "+" + COMMA@12..13 "," + WHITESPACE@13..14 " " + INT_NUMBER@14..16 "92" + R_PAREN@16..17 ")" R_BRACK@17..18 "]" WHITESPACE@18..19 "\n" FN_KW@19..21 "fn" @@ -35,24 +36,25 @@ SOURCE_FILE@0..54 ATTR@34..53 POUND@34..35 "#" L_BRACK@35..36 "[" - PATH@36..39 - PATH_SEGMENT@36..39 - NAME_REF@36..39 - IDENT@36..39 "foo" - TOKEN_TREE@39..53 - L_PAREN@39..40 "(" - WHITESPACE@40..41 "\n" - FN_KW@41..43 "fn" - WHITESPACE@43..44 " " - IDENT@44..47 "foo" - TOKEN_TREE@47..49 - L_PAREN@47..48 "(" - R_PAREN@48..49 ")" - WHITESPACE@49..50 " " - TOKEN_TREE@50..53 - L_CURLY@50..51 "{" - WHITESPACE@51..52 "\n" - R_CURLY@52..53 "}" + META@36..53 + PATH@36..39 + PATH_SEGMENT@36..39 + NAME_REF@36..39 + IDENT@36..39 "foo" + TOKEN_TREE@39..53 + L_PAREN@39..40 "(" + WHITESPACE@40..41 "\n" + FN_KW@41..43 "fn" + WHITESPACE@43..44 " " + IDENT@44..47 "foo" + TOKEN_TREE@47..49 + L_PAREN@47..48 "(" + R_PAREN@48..49 ")" + WHITESPACE@49..50 " " + TOKEN_TREE@50..53 + L_CURLY@50..51 "{" + WHITESPACE@51..52 "\n" + R_CURLY@52..53 "}" WHITESPACE@53..54 "\n" error 53..53: expected R_PAREN error 53..53: expected `]` diff --git a/crates/syntax/test_data/parser/err/0031_block_inner_attrs.rast b/crates/syntax/test_data/parser/err/0031_block_inner_attrs.rast index a443b37db..846279748 100644 --- a/crates/syntax/test_data/parser/err/0031_block_inner_attrs.rast +++ b/crates/syntax/test_data/parser/err/0031_block_inner_attrs.rast @@ -27,14 +27,15 @@ SOURCE_FILE@0..350 POUND@39..40 "#" BANG@40..41 "!" L_BRACK@41..42 "[" - PATH@42..45 - PATH_SEGMENT@42..45 - NAME_REF@42..45 - IDENT@42..45 "doc" - TOKEN_TREE@45..82 - L_PAREN@45..46 "(" - STRING@46..81 "\"Inner attributes not ..." - R_PAREN@81..82 ")" + META@42..82 + PATH@42..45 + PATH_SEGMENT@42..45 + NAME_REF@42..45 + IDENT@42..45 "doc" + TOKEN_TREE@45..82 + L_PAREN@45..46 "(" + STRING@46..81 "\"Inner attributes not ..." + R_PAREN@81..82 ")" R_BRACK@82..83 "]" WHITESPACE@83..92 "\n " COMMENT@92..122 "//! Nor are ModuleDoc ..." @@ -57,28 +58,30 @@ SOURCE_FILE@0..350 POUND@152..153 "#" BANG@153..154 "!" L_BRACK@154..155 "[" - PATH@155..158 - PATH_SEGMENT@155..158 - NAME_REF@155..158 - IDENT@155..158 "doc" - TOKEN_TREE@158..170 - L_PAREN@158..159 "(" - STRING@159..169 "\"Nor here\"" - R_PAREN@169..170 ")" + META@155..170 + PATH@155..158 + PATH_SEGMENT@155..158 + NAME_REF@155..158 + IDENT@155..158 "doc" + TOKEN_TREE@158..170 + L_PAREN@158..159 "(" + STRING@159..169 "\"Nor here\"" + R_PAREN@169..170 ")" R_BRACK@170..171 "]" WHITESPACE@171..180 "\n " ATTR@180..212 POUND@180..181 "#" BANG@181..182 "!" L_BRACK@182..183 "[" - PATH@183..186 - PATH_SEGMENT@183..186 - NAME_REF@183..186 - IDENT@183..186 "doc" - TOKEN_TREE@186..211 - L_PAREN@186..187 "(" - STRING@187..210 "\"We error on each attr\"" - R_PAREN@210..211 ")" + META@183..211 + PATH@183..186 + PATH_SEGMENT@183..186 + NAME_REF@183..186 + IDENT@183..186 "doc" + TOKEN_TREE@186..211 + L_PAREN@186..187 "(" + STRING@187..210 "\"We error on each attr\"" + R_PAREN@210..211 ")" R_BRACK@211..212 "]" WHITESPACE@212..221 "\n " COMMENT@221..251 "//! Nor are ModuleDoc ..." @@ -99,14 +102,15 @@ SOURCE_FILE@0..350 POUND@283..284 "#" BANG@284..285 "!" L_BRACK@285..286 "[" - PATH@286..289 - PATH_SEGMENT@286..289 - NAME_REF@286..289 - IDENT@286..289 "doc" - TOKEN_TREE@289..301 - L_PAREN@289..290 "(" - STRING@290..300 "\"Nor here\"" - R_PAREN@300..301 ")" + META@286..301 + PATH@286..289 + PATH_SEGMENT@286..289 + NAME_REF@286..289 + IDENT@286..289 "doc" + TOKEN_TREE@289..301 + L_PAREN@289..290 "(" + STRING@290..300 "\"Nor here\"" + R_PAREN@300..301 ")" R_BRACK@301..302 "]" WHITESPACE@302..311 "\n " COMMENT@311..341 "//! Nor are ModuleDoc ..." diff --git a/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast b/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast index 672dd054a..b6209639d 100644 --- a/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast +++ b/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast @@ -135,14 +135,15 @@ SOURCE_FILE@0..293 ATTR@210..222 POUND@210..211 "#" L_BRACK@211..212 "[" - PATH@212..215 - PATH_SEGMENT@212..215 - NAME_REF@212..215 - IDENT@212..215 "cfg" - TOKEN_TREE@215..221 - L_PAREN@215..216 "(" - IDENT@216..220 "test" - R_PAREN@220..221 ")" + META@212..221 + PATH@212..215 + PATH_SEGMENT@212..215 + NAME_REF@212..215 + IDENT@212..215 "cfg" + TOKEN_TREE@215..221 + L_PAREN@215..216 "(" + IDENT@216..220 "test" + R_PAREN@220..221 ")" R_BRACK@221..222 "]" WHITESPACE@222..231 "\n " ATTR@231..232 diff --git a/crates/syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast b/crates/syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast index 33bb085e9..84c8e9ee7 100644 --- a/crates/syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast +++ b/crates/syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast @@ -47,14 +47,15 @@ SOURCE_FILE@0..89 ATTR@68..80 POUND@68..69 "#" L_BRACK@69..70 "[" - PATH@70..73 - PATH_SEGMENT@70..73 - NAME_REF@70..73 - IDENT@70..73 "cfg" - TOKEN_TREE@73..79 - L_PAREN@73..74 "(" - IDENT@74..78 "test" - R_PAREN@78..79 ")" + META@70..79 + PATH@70..73 + PATH_SEGMENT@70..73 + NAME_REF@70..73 + IDENT@70..73 "cfg" + TOKEN_TREE@73..79 + L_PAREN@73..74 "(" + IDENT@74..78 "test" + R_PAREN@78..79 ")" R_BRACK@79..80 "]" WHITESPACE@80..85 "\n " R_CURLY@85..86 "}" diff --git a/crates/syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast b/crates/syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast index 8fd8d5e59..7b8b7284f 100644 --- a/crates/syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast +++ b/crates/syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast @@ -15,10 +15,11 @@ SOURCE_FILE@0..48 ATTR@14..18 POUND@14..15 "#" L_BRACK@15..16 "[" - PATH@16..17 - PATH_SEGMENT@16..17 - NAME_REF@16..17 - IDENT@16..17 "A" + META@16..17 + PATH@16..17 + PATH_SEGMENT@16..17 + NAME_REF@16..17 + IDENT@16..17 "A" R_BRACK@17..18 "]" WHITESPACE@18..19 " " BIN_EXPR@19..24 @@ -35,10 +36,11 @@ SOURCE_FILE@0..48 ATTR@29..33 POUND@29..30 "#" L_BRACK@30..31 "[" - PATH@31..32 - PATH_SEGMENT@31..32 - NAME_REF@31..32 - IDENT@31..32 "B" + META@31..32 + PATH@31..32 + PATH_SEGMENT@31..32 + NAME_REF@31..32 + IDENT@31..32 "B" R_BRACK@32..33 "]" WHITESPACE@33..34 " " IF_EXPR@34..44 diff --git a/crates/syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast b/crates/syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast index 9ae271817..402950bcc 100644 --- a/crates/syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast +++ b/crates/syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast @@ -12,18 +12,19 @@ SOURCE_FILE@0..64 ATTR@15..43 POUND@15..16 "#" L_BRACK@16..17 "[" - PATH@17..22 - PATH_SEGMENT@17..22 - NAME_REF@17..22 - IDENT@17..22 "serde" - TOKEN_TREE@22..42 - L_PAREN@22..23 "(" - IDENT@23..27 "with" - WHITESPACE@27..28 " " - EQ@28..29 "=" - WHITESPACE@29..30 " " - STRING@30..41 "\"url_serde\"" - R_PAREN@41..42 ")" + META@17..42 + PATH@17..22 + PATH_SEGMENT@17..22 + NAME_REF@17..22 + IDENT@17..22 "serde" + TOKEN_TREE@22..42 + L_PAREN@22..23 "(" + IDENT@23..27 "with" + WHITESPACE@27..28 " " + EQ@28..29 "=" + WHITESPACE@29..30 " " + STRING@30..41 "\"url_serde\"" + R_PAREN@41..42 ")" R_BRACK@42..43 "]" WHITESPACE@43..48 "\n " VISIBILITY@48..51 diff --git a/crates/syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast b/crates/syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast index 4d09c9f50..db2b645b0 100644 --- a/crates/syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast +++ b/crates/syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast @@ -12,18 +12,19 @@ SOURCE_FILE@0..60 ATTR@15..43 POUND@15..16 "#" L_BRACK@16..17 "[" - PATH@17..22 - PATH_SEGMENT@17..22 - NAME_REF@17..22 - IDENT@17..22 "serde" - TOKEN_TREE@22..42 - L_PAREN@22..23 "(" - IDENT@23..27 "with" - WHITESPACE@27..28 " " - EQ@28..29 "=" - WHITESPACE@29..30 " " - STRING@30..41 "\"url_serde\"" - R_PAREN@41..42 ")" + META@17..42 + PATH@17..22 + PATH_SEGMENT@17..22 + NAME_REF@17..22 + IDENT@17..22 "serde" + TOKEN_TREE@22..42 + L_PAREN@22..23 "(" + IDENT@23..27 "with" + WHITESPACE@27..28 " " + EQ@28..29 "=" + WHITESPACE@29..30 " " + STRING@30..41 "\"url_serde\"" + R_PAREN@41..42 ")" R_BRACK@42..43 "]" WHITESPACE@43..48 "\n " VISIBILITY@48..51 diff --git a/crates/syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast b/crates/syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast index 141a7b203..24ac1d66a 100644 --- a/crates/syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast +++ b/crates/syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast @@ -26,14 +26,15 @@ SOURCE_FILE@0..94 POUND@54..55 "#" BANG@55..56 "!" L_BRACK@56..57 "[" - PATH@57..60 - PATH_SEGMENT@57..60 - NAME_REF@57..60 - IDENT@57..60 "doc" - TOKEN_TREE@60..90 - L_PAREN@60..61 "(" - STRING@61..89 "\"This is also a doc c ..." - R_PAREN@89..90 ")" + META@57..90 + PATH@57..60 + PATH_SEGMENT@57..60 + NAME_REF@57..60 + IDENT@57..60 "doc" + TOKEN_TREE@60..90 + L_PAREN@60..61 "(" + STRING@61..89 "\"This is also a doc c ..." + R_PAREN@89..90 ")" R_BRACK@90..91 "]" WHITESPACE@91..92 "\n" R_CURLY@92..93 "}" diff --git a/crates/syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast b/crates/syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast index ec7a00f1d..7fbeee203 100644 --- a/crates/syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast +++ b/crates/syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast @@ -25,42 +25,45 @@ SOURCE_FILE@0..139 POUND@34..35 "#" BANG@35..36 "!" L_BRACK@36..37 "[" - PATH@37..40 - PATH_SEGMENT@37..40 - NAME_REF@37..40 - IDENT@37..40 "doc" - TOKEN_TREE@40..59 - L_PAREN@40..41 "(" - STRING@41..58 "\"Inner attribute\"" - R_PAREN@58..59 ")" + META@37..59 + PATH@37..40 + PATH_SEGMENT@37..40 + NAME_REF@37..40 + IDENT@37..40 "doc" + TOKEN_TREE@40..59 + L_PAREN@40..41 "(" + STRING@41..58 "\"Inner attribute\"" + R_PAREN@58..59 ")" R_BRACK@59..60 "]" WHITESPACE@60..69 "\n " ATTR@69..86 POUND@69..70 "#" BANG@70..71 "!" L_BRACK@71..72 "[" - PATH@72..75 - PATH_SEGMENT@72..75 - NAME_REF@72..75 - IDENT@72..75 "doc" - TOKEN_TREE@75..85 - L_PAREN@75..76 "(" - STRING@76..84 "\"Can be\"" - R_PAREN@84..85 ")" + META@72..85 + PATH@72..75 + PATH_SEGMENT@72..75 + NAME_REF@72..75 + IDENT@72..75 "doc" + TOKEN_TREE@75..85 + L_PAREN@75..76 "(" + STRING@76..84 "\"Can be\"" + R_PAREN@84..85 ")" R_BRACK@85..86 "]" WHITESPACE@86..95 "\n " ATTR@95..113 POUND@95..96 "#" BANG@96..97 "!" L_BRACK@97..98 "[" - PATH@98..101 - PATH_SEGMENT@98..101 - NAME_REF@98..101 - IDENT@98..101 "doc" - TOKEN_TREE@101..112 - L_PAREN@101..102 "(" - STRING@102..111 "\"Stacked\"" - R_PAREN@111..112 ")" + META@98..112 + PATH@98..101 + PATH_SEGMENT@98..101 + NAME_REF@98..101 + IDENT@98..101 "doc" + TOKEN_TREE@101..112 + L_PAREN@101..102 "(" + STRING@102..111 "\"Stacked\"" + R_PAREN@111..112 ")" R_BRACK@112..113 "]" WHITESPACE@113..122 "\n " MATCH_ARM@122..129 diff --git a/crates/syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast b/crates/syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast index 97924da05..40852f514 100644 --- a/crates/syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast +++ b/crates/syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast @@ -25,18 +25,19 @@ SOURCE_FILE@0..259 ATTR@34..58 POUND@34..35 "#" L_BRACK@35..36 "[" - PATH@36..39 - PATH_SEGMENT@36..39 - NAME_REF@36..39 - IDENT@36..39 "cfg" - TOKEN_TREE@39..57 - L_PAREN@39..40 "(" - IDENT@40..47 "feature" - WHITESPACE@47..48 " " - EQ@48..49 "=" - WHITESPACE@49..50 " " - STRING@50..56 "\"some\"" - R_PAREN@56..57 ")" + META@36..57 + PATH@36..39 + PATH_SEGMENT@36..39 + NAME_REF@36..39 + IDENT@36..39 "cfg" + TOKEN_TREE@39..57 + L_PAREN@39..40 "(" + IDENT@40..47 "feature" + WHITESPACE@47..48 " " + EQ@48..49 "=" + WHITESPACE@49..50 " " + STRING@50..56 "\"some\"" + R_PAREN@56..57 ")" R_BRACK@57..58 "]" WHITESPACE@58..67 "\n " WILDCARD_PAT@67..68 @@ -53,18 +54,19 @@ SOURCE_FILE@0..259 ATTR@84..109 POUND@84..85 "#" L_BRACK@85..86 "[" - PATH@86..89 - PATH_SEGMENT@86..89 - NAME_REF@86..89 - IDENT@86..89 "cfg" - TOKEN_TREE@89..108 - L_PAREN@89..90 "(" - IDENT@90..97 "feature" - WHITESPACE@97..98 " " - EQ@98..99 "=" - WHITESPACE@99..100 " " - STRING@100..107 "\"other\"" - R_PAREN@107..108 ")" + META@86..108 + PATH@86..89 + PATH_SEGMENT@86..89 + NAME_REF@86..89 + IDENT@86..89 "cfg" + TOKEN_TREE@89..108 + L_PAREN@89..90 "(" + IDENT@90..97 "feature" + WHITESPACE@97..98 " " + EQ@98..99 "=" + WHITESPACE@99..100 " " + STRING@100..107 "\"other\"" + R_PAREN@107..108 ")" R_BRACK@108..109 "]" WHITESPACE@109..118 "\n " WILDCARD_PAT@118..119 @@ -81,52 +83,55 @@ SOURCE_FILE@0..259 ATTR@135..159 POUND@135..136 "#" L_BRACK@136..137 "[" - PATH@137..140 - PATH_SEGMENT@137..140 - NAME_REF@137..140 - IDENT@137..140 "cfg" - TOKEN_TREE@140..158 - L_PAREN@140..141 "(" - IDENT@141..148 "feature" - WHITESPACE@148..149 " " - EQ@149..150 "=" - WHITESPACE@150..151 " " - STRING@151..157 "\"many\"" - R_PAREN@157..158 ")" + META@137..158 + PATH@137..140 + PATH_SEGMENT@137..140 + NAME_REF@137..140 + IDENT@137..140 "cfg" + TOKEN_TREE@140..158 + L_PAREN@140..141 "(" + IDENT@141..148 "feature" + WHITESPACE@148..149 " " + EQ@149..150 "=" + WHITESPACE@150..151 " " + STRING@151..157 "\"many\"" + R_PAREN@157..158 ")" R_BRACK@158..159 "]" WHITESPACE@159..168 "\n " ATTR@168..198 POUND@168..169 "#" L_BRACK@169..170 "[" - PATH@170..173 - PATH_SEGMENT@170..173 - NAME_REF@170..173 - IDENT@170..173 "cfg" - TOKEN_TREE@173..197 - L_PAREN@173..174 "(" - IDENT@174..181 "feature" - WHITESPACE@181..182 " " - EQ@182..183 "=" - WHITESPACE@183..184 " " - STRING@184..196 "\"attributes\"" - R_PAREN@196..197 ")" + META@170..197 + PATH@170..173 + PATH_SEGMENT@170..173 + NAME_REF@170..173 + IDENT@170..173 "cfg" + TOKEN_TREE@173..197 + L_PAREN@173..174 "(" + IDENT@174..181 "feature" + WHITESPACE@181..182 " " + EQ@182..183 "=" + WHITESPACE@183..184 " " + STRING@184..196 "\"attributes\"" + R_PAREN@196..197 ")" R_BRACK@197..198 "]" WHITESPACE@198..207 "\n " ATTR@207..233 POUND@207..208 "#" L_BRACK@208..209 "[" - PATH@209..212 - PATH_SEGMENT@209..212 - NAME_REF@209..212 - IDENT@209..212 "cfg" - TOKEN_TREE@212..232 - L_PAREN@212..213 "(" - IDENT@213..220 "feature" - WHITESPACE@220..221 " " - EQ@221..222 "=" - WHITESPACE@222..223 " " - STRING@223..231 "\"before\"" - R_PAREN@231..232 ")" + META@209..232 + PATH@209..212 + PATH_SEGMENT@209..212 + NAME_REF@209..212 + IDENT@209..212 "cfg" + TOKEN_TREE@212..232 + L_PAREN@212..213 "(" + IDENT@213..220 "feature" + WHITESPACE@220..221 " " + EQ@221..222 "=" + WHITESPACE@222..223 " " + STRING@223..231 "\"before\"" + R_PAREN@231..232 ")" R_BRACK@232..233 "]" WHITESPACE@233..242 "\n " WILDCARD_PAT@242..243 diff --git a/crates/syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast b/crates/syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast index 616aa984e..840181383 100644 --- a/crates/syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast +++ b/crates/syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast @@ -10,14 +10,15 @@ SOURCE_FILE@0..64 ATTR@7..26 POUND@7..8 "#" L_BRACK@8..9 "[" - PATH@9..15 - PATH_SEGMENT@9..15 - NAME_REF@9..15 - IDENT@9..15 "derive" - TOKEN_TREE@15..25 - L_PAREN@15..16 "(" - IDENT@16..24 "Lifetime" - R_PAREN@24..25 ")" + META@9..25 + PATH@9..15 + PATH_SEGMENT@9..15 + NAME_REF@9..15 + IDENT@9..15 "derive" + TOKEN_TREE@15..25 + L_PAREN@15..16 "(" + IDENT@16..24 "Lifetime" + R_PAREN@24..25 ")" R_BRACK@25..26 "]" WHITESPACE@26..27 " " LIFETIME@27..29 @@ -28,14 +29,15 @@ SOURCE_FILE@0..64 ATTR@31..46 POUND@31..32 "#" L_BRACK@32..33 "[" - PATH@33..39 - PATH_SEGMENT@33..39 - NAME_REF@33..39 - IDENT@33..39 "derive" - TOKEN_TREE@39..45 - L_PAREN@39..40 "(" - IDENT@40..44 "Type" - R_PAREN@44..45 ")" + META@33..45 + PATH@33..39 + PATH_SEGMENT@33..39 + NAME_REF@33..39 + IDENT@33..39 "derive" + TOKEN_TREE@39..45 + L_PAREN@39..40 "(" + IDENT@40..44 "Type" + R_PAREN@44..45 ")" R_BRACK@45..46 "]" WHITESPACE@46..47 " " NAME@47..48 diff --git a/crates/syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast b/crates/syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast index 54ea2c7c6..5e82214c0 100644 --- a/crates/syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast +++ b/crates/syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast @@ -24,14 +24,15 @@ SOURCE_FILE@0..46 ATTR@20..32 POUND@20..21 "#" L_BRACK@21..22 "[" - PATH@22..25 - PATH_SEGMENT@22..25 - NAME_REF@22..25 - IDENT@22..25 "cfg" - TOKEN_TREE@25..31 - L_PAREN@25..26 "(" - IDENT@26..30 "test" - R_PAREN@30..31 ")" + META@22..31 + PATH@22..25 + PATH_SEGMENT@22..25 + NAME_REF@22..25 + IDENT@22..25 "cfg" + TOKEN_TREE@25..31 + L_PAREN@25..26 "(" + IDENT@26..30 "test" + R_PAREN@30..31 ")" R_BRACK@31..32 "]" WHITESPACE@32..33 " " NAME_REF@33..38 diff --git a/crates/syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast b/crates/syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast index 0342e64f3..178204fec 100644 --- a/crates/syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast +++ b/crates/syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast @@ -15,10 +15,11 @@ SOURCE_FILE@0..82 ATTR@15..19 POUND@15..16 "#" L_BRACK@16..17 "[" - PATH@17..18 - PATH_SEGMENT@17..18 - NAME_REF@17..18 - IDENT@17..18 "A" + META@17..18 + PATH@17..18 + PATH_SEGMENT@17..18 + NAME_REF@17..18 + IDENT@17..18 "A" R_BRACK@18..19 "]" WHITESPACE@19..20 " " CALL_EXPR@20..25 @@ -36,10 +37,11 @@ SOURCE_FILE@0..82 ATTR@31..35 POUND@31..32 "#" L_BRACK@32..33 "[" - PATH@33..34 - PATH_SEGMENT@33..34 - NAME_REF@33..34 - IDENT@33..34 "B" + META@33..34 + PATH@33..34 + PATH_SEGMENT@33..34 + NAME_REF@33..34 + IDENT@33..34 "B" R_BRACK@34..35 "]" WHITESPACE@35..36 " " MACRO_CALL@36..42 @@ -56,19 +58,21 @@ SOURCE_FILE@0..82 ATTR@47..51 POUND@47..48 "#" L_BRACK@48..49 "[" - PATH@49..50 - PATH_SEGMENT@49..50 - NAME_REF@49..50 - IDENT@49..50 "C" + META@49..50 + PATH@49..50 + PATH_SEGMENT@49..50 + NAME_REF@49..50 + IDENT@49..50 "C" R_BRACK@50..51 "]" WHITESPACE@51..52 " " ATTR@52..56 POUND@52..53 "#" L_BRACK@53..54 "[" - PATH@54..55 - PATH_SEGMENT@54..55 - NAME_REF@54..55 - IDENT@54..55 "D" + META@54..55 + PATH@54..55 + PATH_SEGMENT@54..55 + NAME_REF@54..55 + IDENT@54..55 "D" R_BRACK@55..56 "]" WHITESPACE@56..57 " " BLOCK_EXPR@57..59 @@ -79,10 +83,11 @@ SOURCE_FILE@0..82 ATTR@64..68 POUND@64..65 "#" L_BRACK@65..66 "[" - PATH@66..67 - PATH_SEGMENT@66..67 - NAME_REF@66..67 - IDENT@66..67 "D" + META@66..67 + PATH@66..67 + PATH_SEGMENT@66..67 + NAME_REF@66..67 + IDENT@66..67 "D" R_BRACK@67..68 "]" WHITESPACE@68..69 " " RETURN_EXPR@69..78 diff --git a/crates/syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast b/crates/syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast index 3b46e5b47..9daac234a 100644 --- a/crates/syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast +++ b/crates/syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast @@ -19,10 +19,11 @@ SOURCE_FILE@0..47 ATTR@17..21 POUND@17..18 "#" L_BRACK@18..19 "[" - PATH@19..20 - PATH_SEGMENT@19..20 - NAME_REF@19..20 - IDENT@19..20 "A" + META@19..20 + PATH@19..20 + PATH_SEGMENT@19..20 + NAME_REF@19..20 + IDENT@19..20 "A" R_BRACK@20..21 "]" WHITESPACE@21..22 " " MACRO_CALL@22..28 @@ -42,10 +43,11 @@ SOURCE_FILE@0..47 ATTR@36..40 POUND@36..37 "#" L_BRACK@37..38 "[" - PATH@38..39 - PATH_SEGMENT@38..39 - NAME_REF@38..39 - IDENT@38..39 "B" + META@38..39 + PATH@38..39 + PATH_SEGMENT@38..39 + NAME_REF@38..39 + IDENT@38..39 "B" R_BRACK@39..40 "]" WHITESPACE@40..41 " " AMP@41..42 "&" diff --git a/crates/syntax/test_data/parser/inline/ok/0130_let_stmt.rast b/crates/syntax/test_data/parser/inline/ok/0130_let_stmt.rast index 4c07cefa6..c3a79836a 100644 --- a/crates/syntax/test_data/parser/inline/ok/0130_let_stmt.rast +++ b/crates/syntax/test_data/parser/inline/ok/0130_let_stmt.rast @@ -109,10 +109,11 @@ SOURCE_FILE@0..135 ATTR@120..127 POUND@120..121 "#" L_BRACK@121..122 "[" - PATH@122..126 - PATH_SEGMENT@122..126 - NAME_REF@122..126 - IDENT@122..126 "attr" + META@122..126 + PATH@122..126 + PATH_SEGMENT@122..126 + NAME_REF@122..126 + IDENT@122..126 "attr" R_BRACK@126..127 "]" PARAM_LIST@127..129 PIPE@127..128 "|" diff --git a/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast b/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast index c54e64e3f..891eace59 100644 --- a/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast +++ b/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast @@ -10,10 +10,11 @@ SOURCE_FILE@0..26 ATTR@5..16 POUND@5..6 "#" L_BRACK@6..7 "[" - PATH@7..15 - PATH_SEGMENT@7..15 - NAME_REF@7..15 - IDENT@7..15 "must_use" + META@7..15 + PATH@7..15 + PATH_SEGMENT@7..15 + NAME_REF@7..15 + IDENT@7..15 "must_use" R_BRACK@15..16 "]" WHITESPACE@16..17 " " NAME@17..21 diff --git a/crates/syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast b/crates/syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast index a84088bf3..a363e592b 100644 --- a/crates/syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast +++ b/crates/syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast @@ -10,10 +10,11 @@ SOURCE_FILE@0..28 ATTR@5..13 POUND@5..6 "#" L_BRACK@6..7 "[" - PATH@7..12 - PATH_SEGMENT@7..12 - NAME_REF@7..12 - IDENT@7..12 "attr1" + META@7..12 + PATH@7..12 + PATH_SEGMENT@7..12 + NAME_REF@7..12 + IDENT@7..12 "attr1" R_BRACK@12..13 "]" WHITESPACE@13..14 " " IDENT_PAT@14..17 diff --git a/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast b/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast index e9202a612..c606a7c9b 100644 --- a/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast +++ b/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast @@ -87,17 +87,18 @@ SOURCE_FILE@0..102 ATTR@73..86 POUND@73..74 "#" L_BRACK@74..75 "[" - PATH@75..78 - PATH_SEGMENT@75..78 - NAME_REF@75..78 - IDENT@75..78 "cfg" - TOKEN_TREE@78..85 - L_PAREN@78..79 "(" - IDENT@79..82 "any" - TOKEN_TREE@82..84 - L_PAREN@82..83 "(" - R_PAREN@83..84 ")" - R_PAREN@84..85 ")" + META@75..85 + PATH@75..78 + PATH_SEGMENT@75..78 + NAME_REF@75..78 + IDENT@75..78 "cfg" + TOKEN_TREE@78..85 + L_PAREN@78..79 "(" + IDENT@79..82 "any" + TOKEN_TREE@82..84 + L_PAREN@82..83 "(" + R_PAREN@83..84 ")" + R_PAREN@84..85 ")" R_BRACK@85..86 "]" WHITESPACE@86..87 " " NAME_REF@87..88 diff --git a/crates/syntax/test_data/parser/inline/ok/0150_array_attrs.rast b/crates/syntax/test_data/parser/inline/ok/0150_array_attrs.rast index f284aafcd..26cdc2945 100644 --- a/crates/syntax/test_data/parser/inline/ok/0150_array_attrs.rast +++ b/crates/syntax/test_data/parser/inline/ok/0150_array_attrs.rast @@ -31,14 +31,15 @@ SOURCE_FILE@0..40 ATTR@23..35 POUND@23..24 "#" L_BRACK@24..25 "[" - PATH@25..28 - PATH_SEGMENT@25..28 - NAME_REF@25..28 - IDENT@25..28 "cfg" - TOKEN_TREE@28..34 - L_PAREN@28..29 "(" - IDENT@29..33 "test" - R_PAREN@33..34 ")" + META@25..34 + PATH@25..28 + PATH_SEGMENT@25..28 + NAME_REF@25..28 + IDENT@25..28 "cfg" + TOKEN_TREE@28..34 + L_PAREN@28..29 "(" + IDENT@29..33 "test" + R_PAREN@33..34 ")" R_BRACK@34..35 "]" WHITESPACE@35..36 " " INT_NUMBER@36..37 "2" diff --git a/crates/syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast b/crates/syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast index 2905c5f1a..1d20765b0 100644 --- a/crates/syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast +++ b/crates/syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast @@ -23,10 +23,11 @@ SOURCE_FILE@0..34 ATTR@20..27 POUND@20..21 "#" L_BRACK@21..22 "[" - PATH@22..26 - PATH_SEGMENT@22..26 - NAME_REF@22..26 - IDENT@22..26 "attr" + META@22..26 + PATH@22..26 + PATH_SEGMENT@22..26 + NAME_REF@22..26 + IDENT@22..26 "attr" R_BRACK@26..27 "]" WHITESPACE@27..28 " " INT_NUMBER@28..30 "92" diff --git a/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rast b/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rast index d34b21abe..3b6612677 100644 --- a/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rast +++ b/crates/syntax/test_data/parser/inline/ok/0154_tuple_attrs.rast @@ -34,14 +34,15 @@ SOURCE_FILE@0..43 ATTR@26..38 POUND@26..27 "#" L_BRACK@27..28 "[" - PATH@28..31 - PATH_SEGMENT@28..31 - NAME_REF@28..31 - IDENT@28..31 "cfg" - TOKEN_TREE@31..37 - L_PAREN@31..32 "(" - IDENT@32..36 "test" - R_PAREN@36..37 ")" + META@28..37 + PATH@28..31 + PATH_SEGMENT@28..31 + NAME_REF@28..31 + IDENT@28..31 "cfg" + TOKEN_TREE@31..37 + L_PAREN@31..32 "(" + IDENT@32..36 "test" + R_PAREN@36..37 ")" R_BRACK@37..38 "]" WHITESPACE@38..39 " " INT_NUMBER@39..40 "2" diff --git a/crates/syntax/test_data/parser/ok/0006_inner_attributes.rast b/crates/syntax/test_data/parser/ok/0006_inner_attributes.rast index 42587243a..be2d1dc12 100644 --- a/crates/syntax/test_data/parser/ok/0006_inner_attributes.rast +++ b/crates/syntax/test_data/parser/ok/0006_inner_attributes.rast @@ -3,182 +3,192 @@ SOURCE_FILE@0..236 POUND@0..1 "#" BANG@1..2 "!" L_BRACK@2..3 "[" - PATH@3..7 - PATH_SEGMENT@3..7 - NAME_REF@3..7 - IDENT@3..7 "attr" + META@3..7 + PATH@3..7 + PATH_SEGMENT@3..7 + NAME_REF@3..7 + IDENT@3..7 "attr" R_BRACK@7..8 "]" WHITESPACE@8..9 "\n" ATTR@9..23 POUND@9..10 "#" BANG@10..11 "!" L_BRACK@11..12 "[" - PATH@12..16 - PATH_SEGMENT@12..16 - NAME_REF@12..16 - IDENT@12..16 "attr" - TOKEN_TREE@16..22 - L_PAREN@16..17 "(" - TRUE_KW@17..21 "true" - R_PAREN@21..22 ")" + META@12..22 + PATH@12..16 + PATH_SEGMENT@12..16 + NAME_REF@12..16 + IDENT@12..16 "attr" + TOKEN_TREE@16..22 + L_PAREN@16..17 "(" + TRUE_KW@17..21 "true" + R_PAREN@21..22 ")" R_BRACK@22..23 "]" WHITESPACE@23..24 "\n" ATTR@24..39 POUND@24..25 "#" BANG@25..26 "!" L_BRACK@26..27 "[" - PATH@27..31 - PATH_SEGMENT@27..31 - NAME_REF@27..31 - IDENT@27..31 "attr" - TOKEN_TREE@31..38 - L_PAREN@31..32 "(" - IDENT@32..37 "ident" - R_PAREN@37..38 ")" + META@27..38 + PATH@27..31 + PATH_SEGMENT@27..31 + NAME_REF@27..31 + IDENT@27..31 "attr" + TOKEN_TREE@31..38 + L_PAREN@31..32 "(" + IDENT@32..37 "ident" + R_PAREN@37..38 ")" R_BRACK@38..39 "]" WHITESPACE@39..40 "\n" ATTR@40..116 POUND@40..41 "#" BANG@41..42 "!" L_BRACK@42..43 "[" - PATH@43..47 - PATH_SEGMENT@43..47 - NAME_REF@43..47 - IDENT@43..47 "attr" - TOKEN_TREE@47..115 - L_PAREN@47..48 "(" - IDENT@48..53 "ident" - COMMA@53..54 "," - WHITESPACE@54..55 " " - INT_NUMBER@55..58 "100" - COMMA@58..59 "," - WHITESPACE@59..60 " " - TRUE_KW@60..64 "true" - COMMA@64..65 "," - WHITESPACE@65..66 " " - STRING@66..72 "\"true\"" - COMMA@72..73 "," - WHITESPACE@73..74 " " - IDENT@74..79 "ident" - WHITESPACE@79..80 " " - EQ@80..81 "=" - WHITESPACE@81..82 " " - INT_NUMBER@82..85 "100" - COMMA@85..86 "," - WHITESPACE@86..87 " " - IDENT@87..92 "ident" - WHITESPACE@92..93 " " - EQ@93..94 "=" - WHITESPACE@94..95 " " - STRING@95..102 "\"hello\"" - COMMA@102..103 "," - WHITESPACE@103..104 " " - IDENT@104..109 "ident" - TOKEN_TREE@109..114 - L_PAREN@109..110 "(" - INT_NUMBER@110..113 "100" - R_PAREN@113..114 ")" - R_PAREN@114..115 ")" + META@43..115 + PATH@43..47 + PATH_SEGMENT@43..47 + NAME_REF@43..47 + IDENT@43..47 "attr" + TOKEN_TREE@47..115 + L_PAREN@47..48 "(" + IDENT@48..53 "ident" + COMMA@53..54 "," + WHITESPACE@54..55 " " + INT_NUMBER@55..58 "100" + COMMA@58..59 "," + WHITESPACE@59..60 " " + TRUE_KW@60..64 "true" + COMMA@64..65 "," + WHITESPACE@65..66 " " + STRING@66..72 "\"true\"" + COMMA@72..73 "," + WHITESPACE@73..74 " " + IDENT@74..79 "ident" + WHITESPACE@79..80 " " + EQ@80..81 "=" + WHITESPACE@81..82 " " + INT_NUMBER@82..85 "100" + COMMA@85..86 "," + WHITESPACE@86..87 " " + IDENT@87..92 "ident" + WHITESPACE@92..93 " " + EQ@93..94 "=" + WHITESPACE@94..95 " " + STRING@95..102 "\"hello\"" + COMMA@102..103 "," + WHITESPACE@103..104 " " + IDENT@104..109 "ident" + TOKEN_TREE@109..114 + L_PAREN@109..110 "(" + INT_NUMBER@110..113 "100" + R_PAREN@113..114 ")" + R_PAREN@114..115 ")" R_BRACK@115..116 "]" WHITESPACE@116..117 "\n" ATTR@117..130 POUND@117..118 "#" BANG@118..119 "!" L_BRACK@119..120 "[" - PATH@120..124 - PATH_SEGMENT@120..124 - NAME_REF@120..124 - IDENT@120..124 "attr" - TOKEN_TREE@124..129 - L_PAREN@124..125 "(" - INT_NUMBER@125..128 "100" - R_PAREN@128..129 ")" + META@120..129 + PATH@120..124 + PATH_SEGMENT@120..124 + NAME_REF@120..124 + IDENT@120..124 "attr" + TOKEN_TREE@124..129 + L_PAREN@124..125 "(" + INT_NUMBER@125..128 "100" + R_PAREN@128..129 ")" R_BRACK@129..130 "]" WHITESPACE@130..131 "\n" ATTR@131..155 POUND@131..132 "#" BANG@132..133 "!" L_BRACK@133..134 "[" - PATH@134..138 - PATH_SEGMENT@134..138 - NAME_REF@134..138 - IDENT@134..138 "attr" - TOKEN_TREE@138..154 - L_PAREN@138..139 "(" - IDENT@139..146 "enabled" - WHITESPACE@146..147 " " - EQ@147..148 "=" - WHITESPACE@148..149 " " - TRUE_KW@149..153 "true" - R_PAREN@153..154 ")" + META@134..154 + PATH@134..138 + PATH_SEGMENT@134..138 + NAME_REF@134..138 + IDENT@134..138 "attr" + TOKEN_TREE@138..154 + L_PAREN@138..139 "(" + IDENT@139..146 "enabled" + WHITESPACE@146..147 " " + EQ@147..148 "=" + WHITESPACE@148..149 " " + TRUE_KW@149..153 "true" + R_PAREN@153..154 ")" R_BRACK@154..155 "]" WHITESPACE@155..156 "\n" ATTR@156..173 POUND@156..157 "#" BANG@157..158 "!" L_BRACK@158..159 "[" - PATH@159..166 - PATH_SEGMENT@159..166 - NAME_REF@159..166 - IDENT@159..166 "enabled" - TOKEN_TREE@166..172 - L_PAREN@166..167 "(" - TRUE_KW@167..171 "true" - R_PAREN@171..172 ")" + META@159..172 + PATH@159..166 + PATH_SEGMENT@159..166 + NAME_REF@159..166 + IDENT@159..166 "enabled" + TOKEN_TREE@166..172 + L_PAREN@166..167 "(" + TRUE_KW@167..171 "true" + R_PAREN@171..172 ")" R_BRACK@172..173 "]" WHITESPACE@173..174 "\n" ATTR@174..191 POUND@174..175 "#" BANG@175..176 "!" L_BRACK@176..177 "[" - PATH@177..181 - PATH_SEGMENT@177..181 - NAME_REF@177..181 - IDENT@177..181 "attr" - TOKEN_TREE@181..190 - L_PAREN@181..182 "(" - STRING@182..189 "\"hello\"" - R_PAREN@189..190 ")" + META@177..190 + PATH@177..181 + PATH_SEGMENT@177..181 + NAME_REF@177..181 + IDENT@177..181 "attr" + TOKEN_TREE@181..190 + L_PAREN@181..182 "(" + STRING@182..189 "\"hello\"" + R_PAREN@189..190 ")" R_BRACK@190..191 "]" WHITESPACE@191..192 "\n" ATTR@192..214 POUND@192..193 "#" BANG@193..194 "!" L_BRACK@194..195 "[" - PATH@195..199 - PATH_SEGMENT@195..199 - NAME_REF@195..199 - IDENT@195..199 "repr" - TOKEN_TREE@199..213 - L_PAREN@199..200 "(" - IDENT@200..201 "C" - COMMA@201..202 "," - WHITESPACE@202..203 " " - IDENT@203..208 "align" - WHITESPACE@208..209 " " - EQ@209..210 "=" - WHITESPACE@210..211 " " - INT_NUMBER@211..212 "4" - R_PAREN@212..213 ")" + META@195..213 + PATH@195..199 + PATH_SEGMENT@195..199 + NAME_REF@195..199 + IDENT@195..199 "repr" + TOKEN_TREE@199..213 + L_PAREN@199..200 "(" + IDENT@200..201 "C" + COMMA@201..202 "," + WHITESPACE@202..203 " " + IDENT@203..208 "align" + WHITESPACE@208..209 " " + EQ@209..210 "=" + WHITESPACE@210..211 " " + INT_NUMBER@211..212 "4" + R_PAREN@212..213 ")" R_BRACK@213..214 "]" WHITESPACE@214..215 "\n" ATTR@215..236 POUND@215..216 "#" BANG@216..217 "!" L_BRACK@217..218 "[" - PATH@218..222 - PATH_SEGMENT@218..222 - NAME_REF@218..222 - IDENT@218..222 "repr" - TOKEN_TREE@222..235 - L_PAREN@222..223 "(" - IDENT@223..224 "C" - COMMA@224..225 "," - WHITESPACE@225..226 " " - IDENT@226..231 "align" - TOKEN_TREE@231..234 - L_PAREN@231..232 "(" - INT_NUMBER@232..233 "4" - R_PAREN@233..234 ")" - R_PAREN@234..235 ")" + META@218..235 + PATH@218..222 + PATH_SEGMENT@218..222 + NAME_REF@218..222 + IDENT@218..222 "repr" + TOKEN_TREE@222..235 + L_PAREN@222..223 "(" + IDENT@223..224 "C" + COMMA@224..225 "," + WHITESPACE@225..226 " " + IDENT@226..231 "align" + TOKEN_TREE@231..234 + L_PAREN@231..232 "(" + INT_NUMBER@232..233 "4" + R_PAREN@233..234 ")" + R_PAREN@234..235 ")" R_BRACK@235..236 "]" diff --git a/crates/syntax/test_data/parser/ok/0008_mod_item.rast b/crates/syntax/test_data/parser/ok/0008_mod_item.rast index b2c1d791f..8b1e0a52d 100644 --- a/crates/syntax/test_data/parser/ok/0008_mod_item.rast +++ b/crates/syntax/test_data/parser/ok/0008_mod_item.rast @@ -65,10 +65,11 @@ SOURCE_FILE@0..118 POUND@79..80 "#" BANG@80..81 "!" L_BRACK@81..82 "[" - PATH@82..86 - PATH_SEGMENT@82..86 - NAME_REF@82..86 - IDENT@82..86 "attr" + META@82..86 + PATH@82..86 + PATH_SEGMENT@82..86 + NAME_REF@82..86 + IDENT@82..86 "attr" R_BRACK@86..87 "]" WHITESPACE@87..92 "\n " MODULE@92..98 diff --git a/crates/syntax/test_data/parser/ok/0011_outer_attribute.rast b/crates/syntax/test_data/parser/ok/0011_outer_attribute.rast index 478fdba75..ff5877a7b 100644 --- a/crates/syntax/test_data/parser/ok/0011_outer_attribute.rast +++ b/crates/syntax/test_data/parser/ok/0011_outer_attribute.rast @@ -3,23 +3,25 @@ SOURCE_FILE@0..60 ATTR@0..12 POUND@0..1 "#" L_BRACK@1..2 "[" - PATH@2..5 - PATH_SEGMENT@2..5 - NAME_REF@2..5 - IDENT@2..5 "cfg" - TOKEN_TREE@5..11 - L_PAREN@5..6 "(" - IDENT@6..10 "test" - R_PAREN@10..11 ")" + META@2..11 + PATH@2..5 + PATH_SEGMENT@2..5 + NAME_REF@2..5 + IDENT@2..5 "cfg" + TOKEN_TREE@5..11 + L_PAREN@5..6 "(" + IDENT@6..10 "test" + R_PAREN@10..11 ")" R_BRACK@11..12 "]" WHITESPACE@12..13 "\n" ATTR@13..22 POUND@13..14 "#" L_BRACK@14..15 "[" - PATH@15..21 - PATH_SEGMENT@15..21 - NAME_REF@15..21 - IDENT@15..21 "ignore" + META@15..21 + PATH@15..21 + PATH_SEGMENT@15..21 + NAME_REF@15..21 + IDENT@15..21 "ignore" R_BRACK@21..22 "]" WHITESPACE@22..23 "\n" FN_KW@23..25 "fn" @@ -38,15 +40,16 @@ SOURCE_FILE@0..60 ATTR@36..52 POUND@36..37 "#" L_BRACK@37..38 "[" - PATH@38..42 - PATH_SEGMENT@38..42 - NAME_REF@38..42 - IDENT@38..42 "path" - WHITESPACE@42..43 " " - EQ@43..44 "=" - WHITESPACE@44..45 " " - LITERAL@45..51 - STRING@45..51 "\"a.rs\"" + META@38..51 + PATH@38..42 + PATH_SEGMENT@38..42 + NAME_REF@38..42 + IDENT@38..42 "path" + WHITESPACE@42..43 " " + EQ@43..44 "=" + WHITESPACE@44..45 " " + LITERAL@45..51 + STRING@45..51 "\"a.rs\"" R_BRACK@51..52 "]" WHITESPACE@52..53 "\n" MOD_KW@53..56 "mod" diff --git a/crates/syntax/test_data/parser/ok/0017_attr_trailing_comma.rast b/crates/syntax/test_data/parser/ok/0017_attr_trailing_comma.rast index a3e091ad3..94791f771 100644 --- a/crates/syntax/test_data/parser/ok/0017_attr_trailing_comma.rast +++ b/crates/syntax/test_data/parser/ok/0017_attr_trailing_comma.rast @@ -3,15 +3,16 @@ SOURCE_FILE@0..23 ATTR@0..10 POUND@0..1 "#" L_BRACK@1..2 "[" - PATH@2..5 - PATH_SEGMENT@2..5 - NAME_REF@2..5 - IDENT@2..5 "foo" - TOKEN_TREE@5..9 - L_PAREN@5..6 "(" - IDENT@6..7 "a" - COMMA@7..8 "," - R_PAREN@8..9 ")" + META@2..9 + PATH@2..5 + PATH_SEGMENT@2..5 + NAME_REF@2..5 + IDENT@2..5 "foo" + TOKEN_TREE@5..9 + L_PAREN@5..6 "(" + IDENT@6..7 "a" + COMMA@7..8 "," + R_PAREN@8..9 ")" R_BRACK@9..10 "]" WHITESPACE@10..11 "\n" FN_KW@11..13 "fn" diff --git a/crates/syntax/test_data/parser/ok/0035_weird_exprs.rast b/crates/syntax/test_data/parser/ok/0035_weird_exprs.rast index 46b192dc1..20675dbf5 100644 --- a/crates/syntax/test_data/parser/ok/0035_weird_exprs.rast +++ b/crates/syntax/test_data/parser/ok/0035_weird_exprs.rast @@ -11,71 +11,76 @@ SOURCE_FILE@0..3813 POUND@271..272 "#" BANG@272..273 "!" L_BRACK@273..274 "[" - PATH@274..279 - PATH_SEGMENT@274..279 - NAME_REF@274..279 - IDENT@274..279 "allow" - TOKEN_TREE@279..301 - L_PAREN@279..280 "(" - IDENT@280..300 "non_camel_case_types" - R_PAREN@300..301 ")" + META@274..301 + PATH@274..279 + PATH_SEGMENT@274..279 + NAME_REF@274..279 + IDENT@274..279 "allow" + TOKEN_TREE@279..301 + L_PAREN@279..280 "(" + IDENT@280..300 "non_camel_case_types" + R_PAREN@300..301 ")" R_BRACK@301..302 "]" WHITESPACE@302..303 "\n" ATTR@303..323 POUND@303..304 "#" BANG@304..305 "!" L_BRACK@305..306 "[" - PATH@306..311 - PATH_SEGMENT@306..311 - NAME_REF@306..311 - IDENT@306..311 "allow" - TOKEN_TREE@311..322 - L_PAREN@311..312 "(" - IDENT@312..321 "dead_code" - R_PAREN@321..322 ")" + META@306..322 + PATH@306..311 + PATH_SEGMENT@306..311 + NAME_REF@306..311 + IDENT@306..311 "allow" + TOKEN_TREE@311..322 + L_PAREN@311..312 "(" + IDENT@312..321 "dead_code" + R_PAREN@321..322 ")" R_BRACK@322..323 "]" WHITESPACE@323..324 "\n" ATTR@324..351 POUND@324..325 "#" BANG@325..326 "!" L_BRACK@326..327 "[" - PATH@327..332 - PATH_SEGMENT@327..332 - NAME_REF@327..332 - IDENT@327..332 "allow" - TOKEN_TREE@332..350 - L_PAREN@332..333 "(" - IDENT@333..349 "unreachable_code" - R_PAREN@349..350 ")" + META@327..350 + PATH@327..332 + PATH_SEGMENT@327..332 + NAME_REF@327..332 + IDENT@327..332 "allow" + TOKEN_TREE@332..350 + L_PAREN@332..333 "(" + IDENT@333..349 "unreachable_code" + R_PAREN@349..350 ")" R_BRACK@350..351 "]" WHITESPACE@351..352 "\n" ATTR@352..376 POUND@352..353 "#" BANG@353..354 "!" L_BRACK@354..355 "[" - PATH@355..360 - PATH_SEGMENT@355..360 - NAME_REF@355..360 - IDENT@355..360 "allow" - TOKEN_TREE@360..375 - L_PAREN@360..361 "(" - IDENT@361..374 "unused_parens" - R_PAREN@374..375 ")" + META@355..375 + PATH@355..360 + PATH_SEGMENT@355..360 + NAME_REF@355..360 + IDENT@355..360 "allow" + TOKEN_TREE@360..375 + L_PAREN@360..361 "(" + IDENT@361..374 "unused_parens" + R_PAREN@374..375 ")" R_BRACK@375..376 "]" WHITESPACE@376..378 "\n\n" ATTR@378..405 POUND@378..379 "#" BANG@379..380 "!" L_BRACK@380..381 "[" - PATH@381..396 - PATH_SEGMENT@381..396 - NAME_REF@381..396 - IDENT@381..396 "recursion_limit" - WHITESPACE@396..397 " " - EQ@397..398 "=" - WHITESPACE@398..399 " " - LITERAL@399..404 - STRING@399..404 "\"128\"" + META@381..404 + PATH@381..396 + PATH_SEGMENT@381..396 + NAME_REF@381..396 + IDENT@381..396 "recursion_limit" + WHITESPACE@396..397 " " + EQ@397..398 "=" + WHITESPACE@398..399 " " + LITERAL@399..404 + STRING@399..404 "\"128\"" R_BRACK@404..405 "]" WHITESPACE@405..407 "\n\n" USE@407..427 diff --git a/crates/syntax/test_data/parser/ok/0044_let_attrs.rast b/crates/syntax/test_data/parser/ok/0044_let_attrs.rast index af44a4dbe..d0e7a1dbe 100644 --- a/crates/syntax/test_data/parser/ok/0044_let_attrs.rast +++ b/crates/syntax/test_data/parser/ok/0044_let_attrs.rast @@ -17,18 +17,19 @@ SOURCE_FILE@0..166 ATTR@77..106 POUND@77..78 "#" L_BRACK@78..79 "[" - PATH@79..82 - PATH_SEGMENT@79..82 - NAME_REF@79..82 - IDENT@79..82 "cfg" - TOKEN_TREE@82..105 - L_PAREN@82..83 "(" - IDENT@83..90 "feature" - WHITESPACE@90..91 " " - EQ@91..92 "=" - WHITESPACE@92..93 " " - STRING@93..104 "\"backtrace\"" - R_PAREN@104..105 ")" + META@79..105 + PATH@79..82 + PATH_SEGMENT@79..82 + NAME_REF@79..82 + IDENT@79..82 "cfg" + TOKEN_TREE@82..105 + L_PAREN@82..83 "(" + IDENT@83..90 "feature" + WHITESPACE@90..91 " " + EQ@91..92 "=" + WHITESPACE@92..93 " " + STRING@93..104 "\"backtrace\"" + R_PAREN@104..105 ")" R_BRACK@105..106 "]" WHITESPACE@106..111 "\n " LET_KW@111..114 "let" diff --git a/crates/syntax/test_data/parser/ok/0045_block_attrs.rast b/crates/syntax/test_data/parser/ok/0045_block_attrs.rast index 5e50b4e0b..7fbd635d0 100644 --- a/crates/syntax/test_data/parser/ok/0045_block_attrs.rast +++ b/crates/syntax/test_data/parser/ok/0045_block_attrs.rast @@ -15,14 +15,15 @@ SOURCE_FILE@0..764 POUND@17..18 "#" BANG@18..19 "!" L_BRACK@19..20 "[" - PATH@20..23 - PATH_SEGMENT@20..23 - NAME_REF@20..23 - IDENT@20..23 "doc" - TOKEN_TREE@23..56 - L_PAREN@23..24 "(" - STRING@24..55 "\"Inner attributes all ..." - R_PAREN@55..56 ")" + META@20..56 + PATH@20..23 + PATH_SEGMENT@20..23 + NAME_REF@20..23 + IDENT@20..23 "doc" + TOKEN_TREE@23..56 + L_PAREN@23..24 "(" + STRING@24..55 "\"Inner attributes all ..." + R_PAREN@55..56 ")" R_BRACK@56..57 "]" WHITESPACE@57..62 "\n " COMMENT@62..97 "//! As are ModuleDoc ..." @@ -35,28 +36,30 @@ SOURCE_FILE@0..764 POUND@112..113 "#" BANG@113..114 "!" L_BRACK@114..115 "[" - PATH@115..118 - PATH_SEGMENT@115..118 - NAME_REF@115..118 - IDENT@115..118 "doc" - TOKEN_TREE@118..179 - L_PAREN@118..119 "(" - STRING@119..178 "\"Inner attributes are ..." - R_PAREN@178..179 ")" + META@115..179 + PATH@115..118 + PATH_SEGMENT@115..118 + NAME_REF@115..118 + IDENT@115..118 "doc" + TOKEN_TREE@118..179 + L_PAREN@118..119 "(" + STRING@119..178 "\"Inner attributes are ..." + R_PAREN@178..179 ")" R_BRACK@179..180 "]" WHITESPACE@180..189 "\n " ATTR@189..244 POUND@189..190 "#" BANG@190..191 "!" L_BRACK@191..192 "[" - PATH@192..195 - PATH_SEGMENT@192..195 - NAME_REF@192..195 - IDENT@192..195 "doc" - TOKEN_TREE@195..243 - L_PAREN@195..196 "(" - STRING@196..242 "\"Being validated is n ..." - R_PAREN@242..243 ")" + META@192..243 + PATH@192..195 + PATH_SEGMENT@192..195 + NAME_REF@192..195 + IDENT@192..195 "doc" + TOKEN_TREE@195..243 + L_PAREN@195..196 "(" + STRING@196..242 "\"Being validated is n ..." + R_PAREN@242..243 ")" R_BRACK@243..244 "]" WHITESPACE@244..253 "\n " COMMENT@253..288 "//! As are ModuleDoc ..." @@ -71,14 +74,15 @@ SOURCE_FILE@0..764 POUND@310..311 "#" BANG@311..312 "!" L_BRACK@312..313 "[" - PATH@313..316 - PATH_SEGMENT@313..316 - NAME_REF@313..316 - IDENT@313..316 "doc" - TOKEN_TREE@316..408 - L_PAREN@316..317 "(" - STRING@317..407 "\"Inner attributes are ..." - R_PAREN@407..408 ")" + META@313..408 + PATH@313..316 + PATH_SEGMENT@313..316 + NAME_REF@313..316 + IDENT@313..316 "doc" + TOKEN_TREE@316..408 + L_PAREN@316..317 "(" + STRING@317..407 "\"Inner attributes are ..." + R_PAREN@407..408 ")" R_BRACK@408..409 "]" WHITESPACE@409..418 "\n " COMMENT@418..453 "//! As are ModuleDoc ..." @@ -111,14 +115,15 @@ SOURCE_FILE@0..764 ATTR@488..533 POUND@488..489 "#" L_BRACK@489..490 "[" - PATH@490..493 - PATH_SEGMENT@490..493 - NAME_REF@490..493 - IDENT@490..493 "doc" - TOKEN_TREE@493..532 - L_PAREN@493..494 "(" - STRING@494..531 "\"Outer attributes are ..." - R_PAREN@531..532 ")" + META@490..532 + PATH@490..493 + PATH_SEGMENT@490..493 + NAME_REF@490..493 + IDENT@490..493 "doc" + TOKEN_TREE@493..532 + L_PAREN@493..494 "(" + STRING@494..531 "\"Outer attributes are ..." + R_PAREN@531..532 ")" R_BRACK@532..533 "]" WHITESPACE@533..534 " " L_CURLY@534..535 "{" @@ -200,14 +205,15 @@ SOURCE_FILE@0..764 POUND@690..691 "#" BANG@691..692 "!" L_BRACK@692..693 "[" - PATH@693..698 - PATH_SEGMENT@693..698 - NAME_REF@693..698 - IDENT@693..698 "allow" - TOKEN_TREE@698..716 - L_PAREN@698..699 "(" - IDENT@699..715 "unused_variables" - R_PAREN@715..716 ")" + META@693..716 + PATH@693..698 + PATH_SEGMENT@693..698 + NAME_REF@693..698 + IDENT@693..698 "allow" + TOKEN_TREE@698..716 + L_PAREN@698..699 "(" + IDENT@699..715 "unused_variables" + R_PAREN@715..716 ")" R_BRACK@716..717 "]" WHITESPACE@717..718 " " COMMENT@718..755 "// this is `inner_at ..." diff --git a/crates/syntax/test_data/parser/ok/0046_extern_inner_attributes.rast b/crates/syntax/test_data/parser/ok/0046_extern_inner_attributes.rast index 37594769a..854ff9d56 100644 --- a/crates/syntax/test_data/parser/ok/0046_extern_inner_attributes.rast +++ b/crates/syntax/test_data/parser/ok/0046_extern_inner_attributes.rast @@ -14,14 +14,15 @@ SOURCE_FILE@0..87 POUND@47..48 "#" BANG@48..49 "!" L_BRACK@49..50 "[" - PATH@50..53 - PATH_SEGMENT@50..53 - NAME_REF@50..53 - IDENT@50..53 "doc" - TOKEN_TREE@53..83 - L_PAREN@53..54 "(" - STRING@54..82 "\"This is also a doc c ..." - R_PAREN@82..83 ")" + META@50..83 + PATH@50..53 + PATH_SEGMENT@50..53 + NAME_REF@50..53 + IDENT@50..53 "doc" + TOKEN_TREE@53..83 + L_PAREN@53..54 "(" + STRING@54..82 "\"This is also a doc c ..." + R_PAREN@82..83 ")" R_BRACK@83..84 "]" WHITESPACE@84..85 "\n" R_CURLY@85..86 "}" diff --git a/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast b/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast index 88470c41c..f935a0df5 100644 --- a/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast +++ b/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast @@ -10,19 +10,21 @@ SOURCE_FILE@0..519 ATTR@6..14 POUND@6..7 "#" L_BRACK@7..8 "[" - PATH@8..13 - PATH_SEGMENT@8..13 - NAME_REF@8..13 - IDENT@8..13 "attr1" + META@8..13 + PATH@8..13 + PATH_SEGMENT@8..13 + NAME_REF@8..13 + IDENT@8..13 "attr1" R_BRACK@13..14 "]" WHITESPACE@14..15 " " ATTR@15..23 POUND@15..16 "#" L_BRACK@16..17 "[" - PATH@17..22 - PATH_SEGMENT@17..22 - NAME_REF@17..22 - IDENT@17..22 "attr2" + META@17..22 + PATH@17..22 + PATH_SEGMENT@17..22 + NAME_REF@17..22 + IDENT@17..22 "attr2" R_BRACK@22..23 "]" WHITESPACE@23..24 " " IDENT_PAT@24..27 @@ -52,10 +54,11 @@ SOURCE_FILE@0..519 ATTR@44..52 POUND@44..45 "#" L_BRACK@45..46 "[" - PATH@46..51 - PATH_SEGMENT@46..51 - NAME_REF@46..51 - IDENT@46..51 "attr1" + META@46..51 + PATH@46..51 + PATH_SEGMENT@46..51 + NAME_REF@46..51 + IDENT@46..51 "attr1" R_BRACK@51..52 "]" WHITESPACE@52..53 " " IDENT_PAT@53..54 @@ -111,10 +114,11 @@ SOURCE_FILE@0..519 ATTR@106..113 POUND@106..107 "#" L_BRACK@107..108 "[" - PATH@108..112 - PATH_SEGMENT@108..112 - NAME_REF@108..112 - IDENT@108..112 "attr" + META@108..112 + PATH@108..112 + PATH_SEGMENT@108..112 + NAME_REF@108..112 + IDENT@108..112 "attr" R_BRACK@112..113 "]" WHITESPACE@113..114 " " DOT3@114..117 "..." @@ -157,10 +161,11 @@ SOURCE_FILE@0..519 ATTR@146..153 POUND@146..147 "#" L_BRACK@147..148 "[" - PATH@148..152 - PATH_SEGMENT@148..152 - NAME_REF@148..152 - IDENT@148..152 "attr" + META@148..152 + PATH@148..152 + PATH_SEGMENT@148..152 + NAME_REF@148..152 + IDENT@148..152 "attr" R_BRACK@152..153 "]" WHITESPACE@153..154 " " REF_TYPE@154..166 @@ -207,10 +212,11 @@ SOURCE_FILE@0..519 ATTR@197..204 POUND@197..198 "#" L_BRACK@198..199 "[" - PATH@199..203 - PATH_SEGMENT@199..203 - NAME_REF@199..203 - IDENT@199..203 "attr" + META@199..203 + PATH@199..203 + PATH_SEGMENT@199..203 + NAME_REF@199..203 + IDENT@199..203 "attr" R_BRACK@203..204 "]" WHITESPACE@204..205 " " WILDCARD_PAT@205..206 @@ -229,10 +235,11 @@ SOURCE_FILE@0..519 POUND@213..214 "#" WHITESPACE@214..215 " " L_BRACK@215..216 "[" - PATH@216..220 - PATH_SEGMENT@216..220 - NAME_REF@216..220 - IDENT@216..220 "attr" + META@216..220 + PATH@216..220 + PATH_SEGMENT@216..220 + NAME_REF@216..220 + IDENT@216..220 "attr" R_BRACK@220..221 "]" WHITESPACE@221..222 " " IDENT_PAT@222..227 @@ -275,10 +282,11 @@ SOURCE_FILE@0..519 ATTR@257..268 POUND@257..258 "#" L_BRACK@258..259 "[" - PATH@259..267 - PATH_SEGMENT@259..267 - NAME_REF@259..267 - IDENT@259..267 "must_use" + META@259..267 + PATH@259..267 + PATH_SEGMENT@259..267 + NAME_REF@259..267 + IDENT@259..267 "must_use" R_BRACK@267..268 "]" WHITESPACE@268..269 " " NAME@269..273 @@ -300,10 +308,11 @@ SOURCE_FILE@0..519 ATTR@289..296 POUND@289..290 "#" L_BRACK@290..291 "[" - PATH@291..295 - PATH_SEGMENT@291..295 - NAME_REF@291..295 - IDENT@291..295 "attr" + META@291..295 + PATH@291..295 + PATH_SEGMENT@291..295 + NAME_REF@291..295 + IDENT@291..295 "attr" R_BRACK@295..296 "]" WHITESPACE@296..297 " " NAME@297..301 @@ -325,10 +334,11 @@ SOURCE_FILE@0..519 ATTR@317..324 POUND@317..318 "#" L_BRACK@318..319 "[" - PATH@319..323 - PATH_SEGMENT@319..323 - NAME_REF@319..323 - IDENT@319..323 "attr" + META@319..323 + PATH@319..323 + PATH_SEGMENT@319..323 + NAME_REF@319..323 + IDENT@319..323 "attr" R_BRACK@323..324 "]" WHITESPACE@324..325 " " AMP@325..326 "&" @@ -357,10 +367,11 @@ SOURCE_FILE@0..519 ATTR@350..357 POUND@350..351 "#" L_BRACK@351..352 "[" - PATH@352..356 - PATH_SEGMENT@352..356 - NAME_REF@352..356 - IDENT@352..356 "attr" + META@352..356 + PATH@352..356 + PATH_SEGMENT@352..356 + NAME_REF@352..356 + IDENT@352..356 "attr" R_BRACK@356..357 "]" WHITESPACE@357..358 " " AMP@358..359 "&" @@ -391,10 +402,11 @@ SOURCE_FILE@0..519 ATTR@387..394 POUND@387..388 "#" L_BRACK@388..389 "[" - PATH@389..393 - PATH_SEGMENT@389..393 - NAME_REF@389..393 - IDENT@389..393 "attr" + META@389..393 + PATH@389..393 + PATH_SEGMENT@389..393 + NAME_REF@389..393 + IDENT@389..393 "attr" R_BRACK@393..394 "]" WHITESPACE@394..395 " " AMP@395..396 "&" @@ -426,10 +438,11 @@ SOURCE_FILE@0..519 ATTR@423..430 POUND@423..424 "#" L_BRACK@424..425 "[" - PATH@425..429 - PATH_SEGMENT@425..429 - NAME_REF@425..429 - IDENT@425..429 "attr" + META@425..429 + PATH@425..429 + PATH_SEGMENT@425..429 + NAME_REF@425..429 + IDENT@425..429 "attr" R_BRACK@429..430 "]" WHITESPACE@430..431 " " AMP@431..432 "&" @@ -457,10 +470,11 @@ SOURCE_FILE@0..519 ATTR@458..465 POUND@458..459 "#" L_BRACK@459..460 "[" - PATH@460..464 - PATH_SEGMENT@460..464 - NAME_REF@460..464 - IDENT@460..464 "attr" + META@460..464 + PATH@460..464 + PATH_SEGMENT@460..464 + NAME_REF@460..464 + IDENT@460..464 "attr" R_BRACK@464..465 "]" WHITESPACE@465..466 " " NAME@466..470 @@ -489,10 +503,11 @@ SOURCE_FILE@0..519 ATTR@491..498 POUND@491..492 "#" L_BRACK@492..493 "[" - PATH@493..497 - PATH_SEGMENT@493..497 - NAME_REF@493..497 - IDENT@493..497 "attr" + META@493..497 + PATH@493..497 + PATH_SEGMENT@493..497 + NAME_REF@493..497 + IDENT@493..497 "attr" R_BRACK@497..498 "]" WHITESPACE@498..499 " " NAME@499..503 diff --git a/crates/syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast b/crates/syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast index 87d8ebcba..97416f16a 100644 --- a/crates/syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast +++ b/crates/syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast @@ -5,10 +5,11 @@ SOURCE_FILE@0..65 ATTR@14..29 POUND@14..15 "#" L_BRACK@15..16 "[" - PATH@16..28 - PATH_SEGMENT@16..28 - NAME_REF@16..28 - IDENT@16..28 "macro_export" + META@16..28 + PATH@16..28 + PATH_SEGMENT@16..28 + NAME_REF@16..28 + IDENT@16..28 "macro_export" R_BRACK@28..29 "]" WHITESPACE@29..30 "\n" MACRO_RULES_KW@30..41 "macro_rules" diff --git a/crates/syntax/test_data/parser/ok/0062_macro_2.0.rast b/crates/syntax/test_data/parser/ok/0062_macro_2.0.rast index 0c22c31a4..e75848f0f 100644 --- a/crates/syntax/test_data/parser/ok/0062_macro_2.0.rast +++ b/crates/syntax/test_data/parser/ok/0062_macro_2.0.rast @@ -55,10 +55,11 @@ SOURCE_FILE@0..349 ATTR@95..102 POUND@95..96 "#" L_BRACK@96..97 "[" - PATH@97..101 - PATH_SEGMENT@97..101 - NAME_REF@97..101 - IDENT@97..101 "test" + META@97..101 + PATH@97..101 + PATH_SEGMENT@97..101 + NAME_REF@97..101 + IDENT@97..101 "test" R_BRACK@101..102 "]" WHITESPACE@102..103 "\n" FN_KW@103..105 "fn" diff --git a/crates/syntax/test_data/parser/ok/0063_variadic_fun.rast b/crates/syntax/test_data/parser/ok/0063_variadic_fun.rast index f7c094898..dcc4105c9 100644 --- a/crates/syntax/test_data/parser/ok/0063_variadic_fun.rast +++ b/crates/syntax/test_data/parser/ok/0063_variadic_fun.rast @@ -96,14 +96,15 @@ SOURCE_FILE@0..126 ATTR@92..105 POUND@92..93 "#" L_BRACK@93..94 "[" - PATH@94..97 - PATH_SEGMENT@94..97 - NAME_REF@94..97 - IDENT@94..97 "cfg" - TOKEN_TREE@97..104 - L_PAREN@97..98 "(" - IDENT@98..103 "never" - R_PAREN@103..104 ")" + META@94..104 + PATH@94..97 + PATH_SEGMENT@94..97 + NAME_REF@94..97 + IDENT@94..97 "cfg" + TOKEN_TREE@97..104 + L_PAREN@97..98 "(" + IDENT@98..103 "never" + R_PAREN@103..104 ")" R_BRACK@104..105 "]" WHITESPACE@105..106 " " SLICE_PAT@106..115 diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 997770958..c4fc91386 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -11,7 +11,7 @@ anyhow = "1.0.26" flate2 = "1.0" proc-macro2 = "1.0.8" quote = "1.0.2" -ungrammar = "=1.13" +ungrammar = "=1.14" walkdir = "2.3.1" write-json = "0.1.0" xshell = "0.1" diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 0fd1d13e6..fe37d0245 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -184,7 +184,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "ITEM_LIST", "ASSOC_ITEM_LIST", "ATTR", - "META_ITEM", // not an item actually + "META", "USE_TREE", "USE_TREE_LIST", "PATH", -- cgit v1.2.3 From 99d40e7a3a22604690753322f9274bc91fa03de4 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 11 Jun 2021 18:20:15 +0200 Subject: Don't stringify `cfg_attr`-gated attributes This preserves the assigned `TokenId`s --- crates/hir_def/src/attr.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 3886b6c04..d9f9fadc1 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -106,7 +106,9 @@ impl RawAttrs { ) -> Self { let entries = collect_attrs(owner) .flat_map(|(id, attr)| match attr { - Either::Left(attr) => Attr::from_src(db, attr, hygiene, id), + Either::Left(attr) => { + attr.meta().and_then(|meta| Attr::from_src(db, meta, hygiene, id)) + } Either::Right(comment) => comment.doc_comment().map(|doc| Attr { id, input: Some(Interned::new(AttrInput::Literal(SmolStr::new(doc)))), @@ -172,10 +174,9 @@ impl RawAttrs { let index = attr.id; let attrs = parts.filter(|a| !a.is_empty()).filter_map(|attr| { let tree = Subtree { delimiter: None, token_trees: attr.to_vec() }; - let attr = ast::Attr::parse(&format!("#[{}]", tree)).ok()?; // FIXME hygiene let hygiene = Hygiene::new_unhygienic(); - Attr::from_src(db, attr, &hygiene, index) + Attr::from_tt(db, &tree, &hygiene, index) }); let cfg_options = &crate_graph[krate].cfg_options; @@ -664,7 +665,7 @@ impl fmt::Display for AttrInput { impl Attr { fn from_src( db: &dyn DefDatabase, - ast: ast::Attr, + ast: ast::Meta, hygiene: &Hygiene, id: AttrId, ) -> Option { @@ -683,6 +684,19 @@ impl Attr { Some(Attr { id, path, input }) } + fn from_tt( + db: &dyn DefDatabase, + tt: &tt::Subtree, + hygiene: &Hygiene, + id: AttrId, + ) -> Option { + let (parse, _) = + mbe::token_tree_to_syntax_node(tt, hir_expand::FragmentKind::MetaItem).ok()?; + let ast = ast::Meta::cast(parse.syntax_node())?; + + Self::from_src(db, ast, hygiene, id) + } + /// Parses this attribute as a `#[derive]`, returns an iterator that yields all contained paths /// to derive macros. /// -- cgit v1.2.3