aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/syntax')
-rw-r--r--crates/syntax/Cargo.toml2
-rw-r--r--crates/syntax/src/algo.rs8
-rw-r--r--crates/syntax/src/ast/generated/nodes.rs40
-rw-r--r--crates/syntax/src/ast/make.rs8
-rw-r--r--crates/syntax/src/ast/node_ext.rs22
-rw-r--r--crates/syntax/src/parsing/reparsing.rs5
-rw-r--r--crates/syntax/src/validation.rs2
-rw-r--r--crates/syntax/test_data/parser/err/0018_incomplete_fn.rast6
-rw-r--r--crates/syntax/test_data/parser/err/0035_use_recover.rast3
-rw-r--r--crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast15
-rw-r--r--crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast15
-rw-r--r--crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0052_path_type.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0067_crate_path.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rast28
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rs4
-rw-r--r--crates/syntax/test_data/parser/ok/0013_use_path_self_super.rast9
-rw-r--r--crates/syntax/test_data/parser/ok/0020_type_param_bounds.rast3
-rw-r--r--crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rast3
26 files changed, 162 insertions, 53 deletions
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml
index cfeaed9e6..52394b337 100644
--- a/crates/syntax/Cargo.toml
+++ b/crates/syntax/Cargo.toml
@@ -12,7 +12,7 @@ doctest = false
12 12
13[dependencies] 13[dependencies]
14itertools = "0.10.0" 14itertools = "0.10.0"
15rowan = "0.10.0" 15rowan = "0.10.3"
16rustc_lexer = { version = "697.0.0", package = "rustc-ap-rustc_lexer" } 16rustc_lexer = { version = "697.0.0", package = "rustc-ap-rustc_lexer" }
17rustc-hash = "1.1.0" 17rustc-hash = "1.1.0"
18arrayvec = "0.5.1" 18arrayvec = "0.5.1"
diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs
index 384d031e7..827ae78f9 100644
--- a/crates/syntax/src/algo.rs
+++ b/crates/syntax/src/algo.rs
@@ -45,7 +45,7 @@ pub fn find_node_at_offset<N: AstNode>(syntax: &SyntaxNode, offset: TextSize) ->
45} 45}
46 46
47pub fn find_node_at_range<N: AstNode>(syntax: &SyntaxNode, range: TextRange) -> Option<N> { 47pub fn find_node_at_range<N: AstNode>(syntax: &SyntaxNode, range: TextRange) -> Option<N> {
48 find_covering_element(syntax, range).ancestors().find_map(N::cast) 48 syntax.covering_element(range).ancestors().find_map(N::cast)
49} 49}
50 50
51/// Skip to next non `trivia` token 51/// Skip to next non `trivia` token
@@ -74,10 +74,6 @@ pub fn non_trivia_sibling(element: SyntaxElement, direction: Direction) -> Optio
74 } 74 }
75} 75}
76 76
77pub fn find_covering_element(root: &SyntaxNode, range: TextRange) -> SyntaxElement {
78 root.covering_element(range)
79}
80
81pub fn least_common_ancestor(u: &SyntaxNode, v: &SyntaxNode) -> Option<SyntaxNode> { 77pub fn least_common_ancestor(u: &SyntaxNode, v: &SyntaxNode) -> Option<SyntaxNode> {
82 if u == v { 78 if u == v {
83 return Some(u.clone()); 79 return Some(u.clone());
@@ -883,7 +879,7 @@ use crate::AstNode;
883 879
884 replacements: 880 replacements:
885 881
886 Line 2: Node(NAME_REF@5..14) -> crate 882 Line 2: Token(IDENT@5..14 "text_edit") -> crate
887 Line 2: Token([email protected] "TextEdit") -> AstNode 883 Line 2: Token([email protected] "TextEdit") -> AstNode
888 Line 2: Token([email protected] "\n\n") -> "\n" 884 Line 2: Token([email protected] "\n\n") -> "\n"
889 885
diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs
index 92ed2ee9d..1d722db3c 100644
--- a/crates/syntax/src/ast/generated/nodes.rs
+++ b/crates/syntax/src/ast/generated/nodes.rs
@@ -18,6 +18,9 @@ pub struct NameRef {
18} 18}
19impl NameRef { 19impl NameRef {
20 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } 20 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
21 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
22 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
23 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
21} 24}
22#[derive(Debug, Clone, PartialEq, Eq, Hash)] 25#[derive(Debug, Clone, PartialEq, Eq, Hash)]
23pub struct Lifetime { 26pub struct Lifetime {
@@ -42,9 +45,6 @@ pub struct PathSegment {
42 pub(crate) syntax: SyntaxNode, 45 pub(crate) syntax: SyntaxNode,
43} 46}
44impl PathSegment { 47impl PathSegment {
45 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
46 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
47 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
48 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } 48 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
49 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 49 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
50 pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) } 50 pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) }
@@ -931,6 +931,15 @@ impl WhileExpr {
931 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 931 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
932} 932}
933#[derive(Debug, Clone, PartialEq, Eq, Hash)] 933#[derive(Debug, Clone, PartialEq, Eq, Hash)]
934pub struct YieldExpr {
935 pub(crate) syntax: SyntaxNode,
936}
937impl ast::AttrsOwner for YieldExpr {}
938impl YieldExpr {
939 pub fn yield_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![yield]) }
940 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
941}
942#[derive(Debug, Clone, PartialEq, Eq, Hash)]
934pub struct Label { 943pub struct Label {
935 pub(crate) syntax: SyntaxNode, 944 pub(crate) syntax: SyntaxNode,
936} 945}
@@ -1334,6 +1343,7 @@ pub enum Expr {
1334 TryExpr(TryExpr), 1343 TryExpr(TryExpr),
1335 TupleExpr(TupleExpr), 1344 TupleExpr(TupleExpr),
1336 WhileExpr(WhileExpr), 1345 WhileExpr(WhileExpr),
1346 YieldExpr(YieldExpr),
1337} 1347}
1338#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1348#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1339pub enum Item { 1349pub enum Item {
@@ -2386,6 +2396,17 @@ impl AstNode for WhileExpr {
2386 } 2396 }
2387 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2397 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2388} 2398}
2399impl AstNode for YieldExpr {
2400 fn can_cast(kind: SyntaxKind) -> bool { kind == YIELD_EXPR }
2401 fn cast(syntax: SyntaxNode) -> Option<Self> {
2402 if Self::can_cast(syntax.kind()) {
2403 Some(Self { syntax })
2404 } else {
2405 None
2406 }
2407 }
2408 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2409}
2389impl AstNode for Label { 2410impl AstNode for Label {
2390 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } 2411 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
2391 fn cast(syntax: SyntaxNode) -> Option<Self> { 2412 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3028,6 +3049,9 @@ impl From<TupleExpr> for Expr {
3028impl From<WhileExpr> for Expr { 3049impl From<WhileExpr> for Expr {
3029 fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) } 3050 fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) }
3030} 3051}
3052impl From<YieldExpr> for Expr {
3053 fn from(node: YieldExpr) -> Expr { Expr::YieldExpr(node) }
3054}
3031impl AstNode for Expr { 3055impl AstNode for Expr {
3032 fn can_cast(kind: SyntaxKind) -> bool { 3056 fn can_cast(kind: SyntaxKind) -> bool {
3033 match kind { 3057 match kind {
@@ -3035,7 +3059,8 @@ impl AstNode for Expr {
3035 | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR 3059 | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR
3036 | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR 3060 | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
3037 | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR 3061 | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR
3038 | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true, 3062 | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR
3063 | YIELD_EXPR => true,
3039 _ => false, 3064 _ => false,
3040 } 3065 }
3041 } 3066 }
@@ -3071,6 +3096,7 @@ impl AstNode for Expr {
3071 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }), 3096 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
3072 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }), 3097 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
3073 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }), 3098 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
3099 YIELD_EXPR => Expr::YieldExpr(YieldExpr { syntax }),
3074 _ => return None, 3100 _ => return None,
3075 }; 3101 };
3076 Some(res) 3102 Some(res)
@@ -3107,6 +3133,7 @@ impl AstNode for Expr {
3107 Expr::TryExpr(it) => &it.syntax, 3133 Expr::TryExpr(it) => &it.syntax,
3108 Expr::TupleExpr(it) => &it.syntax, 3134 Expr::TupleExpr(it) => &it.syntax,
3109 Expr::WhileExpr(it) => &it.syntax, 3135 Expr::WhileExpr(it) => &it.syntax,
3136 Expr::YieldExpr(it) => &it.syntax,
3110 } 3137 }
3111 } 3138 }
3112} 3139}
@@ -3983,6 +4010,11 @@ impl std::fmt::Display for WhileExpr {
3983 std::fmt::Display::fmt(self.syntax(), f) 4010 std::fmt::Display::fmt(self.syntax(), f)
3984 } 4011 }
3985} 4012}
4013impl std::fmt::Display for YieldExpr {
4014 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4015 std::fmt::Display::fmt(self.syntax(), f)
4016 }
4017}
3986impl std::fmt::Display for Label { 4018impl std::fmt::Display for Label {
3987 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4019 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3988 std::fmt::Display::fmt(self.syntax(), f) 4020 std::fmt::Display::fmt(self.syntax(), f)
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs
index 1ed8a96e5..9ffc3ae11 100644
--- a/crates/syntax/src/ast/make.rs
+++ b/crates/syntax/src/ast/make.rs
@@ -108,8 +108,12 @@ pub fn use_tree_list(use_trees: impl IntoIterator<Item = ast::UseTree>) -> ast::
108 ast_from_text(&format!("use {{{}}};", use_trees)) 108 ast_from_text(&format!("use {{{}}};", use_trees))
109} 109}
110 110
111pub fn use_(use_tree: ast::UseTree) -> ast::Use { 111pub fn use_(visibility: Option<ast::Visibility>, use_tree: ast::UseTree) -> ast::Use {
112 ast_from_text(&format!("use {};", use_tree)) 112 let visibility = match visibility {
113 None => String::new(),
114 Some(it) => format!("{} ", it),
115 };
116 ast_from_text(&format!("{}use {};", visibility, use_tree))
113} 117}
114 118
115pub fn record_expr_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField { 119pub fn record_expr_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField {
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index 27381ba80..b8ce71d27 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -156,14 +156,28 @@ impl ast::PathSegment {
156 .expect("segments are always nested in paths") 156 .expect("segments are always nested in paths")
157 } 157 }
158 158
159 pub fn crate_token(&self) -> Option<SyntaxToken> {
160 self.name_ref().and_then(|it| it.crate_token())
161 }
162
163 pub fn self_token(&self) -> Option<SyntaxToken> {
164 self.name_ref().and_then(|it| it.self_token())
165 }
166
167 pub fn super_token(&self) -> Option<SyntaxToken> {
168 self.name_ref().and_then(|it| it.super_token())
169 }
170
159 pub fn kind(&self) -> Option<PathSegmentKind> { 171 pub fn kind(&self) -> Option<PathSegmentKind> {
160 let res = if let Some(name_ref) = self.name_ref() { 172 let res = if let Some(name_ref) = self.name_ref() {
161 PathSegmentKind::Name(name_ref) 173 match name_ref.syntax().first_token().map(|it| it.kind()) {
174 Some(T![self]) => PathSegmentKind::SelfKw,
175 Some(T![super]) => PathSegmentKind::SuperKw,
176 Some(T![crate]) => PathSegmentKind::CrateKw,
177 _ => PathSegmentKind::Name(name_ref),
178 }
162 } else { 179 } else {
163 match self.syntax().first_child_or_token()?.kind() { 180 match self.syntax().first_child_or_token()?.kind() {
164 T![self] => PathSegmentKind::SelfKw,
165 T![super] => PathSegmentKind::SuperKw,
166 T![crate] => PathSegmentKind::CrateKw,
167 T![<] => { 181 T![<] => {
168 // <T> or <T as Trait> 182 // <T> or <T as Trait>
169 // T is any TypeRef, Trait has to be a PathType 183 // T is any TypeRef, Trait has to be a PathType
diff --git a/crates/syntax/src/parsing/reparsing.rs b/crates/syntax/src/parsing/reparsing.rs
index 78eaf3410..76f01084c 100644
--- a/crates/syntax/src/parsing/reparsing.rs
+++ b/crates/syntax/src/parsing/reparsing.rs
@@ -10,7 +10,6 @@ use parser::Reparser;
10use text_edit::Indel; 10use text_edit::Indel;
11 11
12use crate::{ 12use crate::{
13 algo,
14 parsing::{ 13 parsing::{
15 lexer::{lex_single_syntax_kind, tokenize, Token}, 14 lexer::{lex_single_syntax_kind, tokenize, Token},
16 text_token_source::TextTokenSource, 15 text_token_source::TextTokenSource,
@@ -41,7 +40,7 @@ fn reparse_token<'node>(
41 root: &'node SyntaxNode, 40 root: &'node SyntaxNode,
42 edit: &Indel, 41 edit: &Indel,
43) -> Option<(GreenNode, Vec<SyntaxError>, TextRange)> { 42) -> Option<(GreenNode, Vec<SyntaxError>, TextRange)> {
44 let prev_token = algo::find_covering_element(root, edit.delete).as_token()?.clone(); 43 let prev_token = root.covering_element(edit.delete).as_token()?.clone();
45 let prev_token_kind = prev_token.kind(); 44 let prev_token_kind = prev_token.kind();
46 match prev_token_kind { 45 match prev_token_kind {
47 WHITESPACE | COMMENT | IDENT | STRING => { 46 WHITESPACE | COMMENT | IDENT | STRING => {
@@ -124,7 +123,7 @@ fn is_contextual_kw(text: &str) -> bool {
124} 123}
125 124
126fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(SyntaxNode, Reparser)> { 125fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(SyntaxNode, Reparser)> {
127 let node = algo::find_covering_element(node, range); 126 let node = node.covering_element(range);
128 127
129 let mut ancestors = match node { 128 let mut ancestors = match node {
130 NodeOrToken::Token(it) => it.parent().ancestors(), 129 NodeOrToken::Token(it) => it.parent().ancestors(),
diff --git a/crates/syntax/src/validation.rs b/crates/syntax/src/validation.rs
index bfa2dc4ba..7901580ee 100644
--- a/crates/syntax/src/validation.rs
+++ b/crates/syntax/src/validation.rs
@@ -256,7 +256,7 @@ fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec<SyntaxErro
256 )); 256 ));
257 } 257 }
258 } else if let Some(token) = segment.super_token() { 258 } else if let Some(token) = segment.super_token() {
259 if !all_supers(&path) { 259 if segment.coloncolon_token().is_some() || !all_supers(&path) {
260 errors.push(SyntaxError::new( 260 errors.push(SyntaxError::new(
261 "The `super` keyword may only be preceded by other `super`s", 261 "The `super` keyword may only be preceded by other `super`s",
262 token.text_range(), 262 token.text_range(),
diff --git a/crates/syntax/test_data/parser/err/0018_incomplete_fn.rast b/crates/syntax/test_data/parser/err/0018_incomplete_fn.rast
index 72939fc98..060f47dc4 100644
--- a/crates/syntax/test_data/parser/err/0018_incomplete_fn.rast
+++ b/crates/syntax/test_data/parser/err/0018_incomplete_fn.rast
@@ -49,7 +49,8 @@ [email protected]
49 [email protected] 49 [email protected]
50 [email protected] 50 [email protected]
51 [email protected] 51 [email protected]
52 [email protected] "self" 52 [email protected]
53 [email protected] "self"
53 [email protected] "." 54 [email protected] "."
54 [email protected] 55 [email protected]
55 [email protected] "scopes" 56 [email protected] "scopes"
@@ -66,7 +67,8 @@ [email protected]
66 [email protected] 67 [email protected]
67 [email protected] 68 [email protected]
68 [email protected] 69 [email protected]
69 [email protected] "self" 70 [email protected]
71 [email protected] "self"
70 [email protected] "." 72 [email protected] "."
71 [email protected] 73 [email protected]
72 [email protected] "scopes" 74 [email protected] "scopes"
diff --git a/crates/syntax/test_data/parser/err/0035_use_recover.rast b/crates/syntax/test_data/parser/err/0035_use_recover.rast
index 2f03709eb..a95151bc5 100644
--- a/crates/syntax/test_data/parser/err/0035_use_recover.rast
+++ b/crates/syntax/test_data/parser/err/0035_use_recover.rast
@@ -24,7 +24,8 @@ [email protected]
24 [email protected] 24 [email protected]
25 [email protected] 25 [email protected]
26 [email protected] 26 [email protected]
27 [email protected] "crate" 27 [email protected]
28 [email protected] "crate"
28 [email protected] "::" 29 [email protected] "::"
29 [email protected] 30 [email protected]
30 [email protected] 31 [email protected]
diff --git a/crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast b/crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast
index 284c8715b..7449b5ddf 100644
--- a/crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast
+++ b/crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast
@@ -6,7 +6,8 @@ [email protected]
6 [email protected] 6 [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "::" 8 [email protected] "::"
9 [email protected] "crate" 9 [email protected]
10 [email protected] "crate"
10 [email protected] ";" 11 [email protected] ";"
11 [email protected] "\n" 12 [email protected] "\n"
12 [email protected] 13 [email protected]
@@ -18,7 +19,8 @@ [email protected]
18 [email protected] 19 [email protected]
19 [email protected] 20 [email protected]
20 [email protected] 21 [email protected]
21 [email protected] "crate" 22 [email protected]
23 [email protected] "crate"
22 [email protected] "," 24 [email protected] ","
23 [email protected] " " 25 [email protected] " "
24 [email protected] 26 [email protected]
@@ -35,7 +37,8 @@ [email protected]
35 [email protected] 37 [email protected]
36 [email protected] 38 [email protected]
37 [email protected] 39 [email protected]
38 [email protected] "crate" 40 [email protected]
41 [email protected] "crate"
39 [email protected] "::" 42 [email protected] "::"
40 [email protected] 43 [email protected]
41 [email protected] 44 [email protected]
@@ -63,7 +66,8 @@ [email protected]
63 [email protected] "hello" 66 [email protected] "hello"
64 [email protected] "::" 67 [email protected] "::"
65 [email protected] 68 [email protected]
66 [email protected] "crate" 69 [email protected]
70 [email protected] "crate"
67 [email protected] ";" 71 [email protected] ";"
68 [email protected] "\n" 72 [email protected] "\n"
69 [email protected] 73 [email protected]
@@ -78,7 +82,8 @@ [email protected]
78 [email protected] "hello" 82 [email protected] "hello"
79 [email protected] "::" 83 [email protected] "::"
80 [email protected] 84 [email protected]
81 [email protected] "crate" 85 [email protected]
86 [email protected] "crate"
82 [email protected] "::" 87 [email protected] "::"
83 [email protected] 88 [email protected]
84 [email protected] 89 [email protected]
diff --git a/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast b/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast
index 2049a9d72..271f8d780 100644
--- a/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast
+++ b/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast
@@ -6,7 +6,8 @@ [email protected]
6 [email protected] 6 [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "::" 8 [email protected] "::"
9 [email protected] "super" 9 [email protected]
10 [email protected] "super"
10 [email protected] ";" 11 [email protected] ";"
11 [email protected] "\n" 12 [email protected] "\n"
12 [email protected] 13 [email protected]
@@ -20,7 +21,8 @@ [email protected]
20 [email protected] "a" 21 [email protected] "a"
21 [email protected] "::" 22 [email protected] "::"
22 [email protected] 23 [email protected]
23 [email protected] "super" 24 [email protected]
25 [email protected] "super"
24 [email protected] ";" 26 [email protected] ";"
25 [email protected] "\n" 27 [email protected] "\n"
26 [email protected] 28 [email protected]
@@ -31,14 +33,16 @@ [email protected]
31 [email protected] 33 [email protected]
32 [email protected] 34 [email protected]
33 [email protected] 35 [email protected]
34 [email protected] "super" 36 [email protected]
37 [email protected] "super"
35 [email protected] "::" 38 [email protected] "::"
36 [email protected] 39 [email protected]
37 [email protected] 40 [email protected]
38 [email protected] "a" 41 [email protected] "a"
39 [email protected] "::" 42 [email protected] "::"
40 [email protected] 43 [email protected]
41 [email protected] "super" 44 [email protected]
45 [email protected] "super"
42 [email protected] ";" 46 [email protected] ";"
43 [email protected] "\n" 47 [email protected] "\n"
44 [email protected] 48 [email protected]
@@ -56,7 +60,8 @@ [email protected]
56 [email protected] 60 [email protected]
57 [email protected] 61 [email protected]
58 [email protected] 62 [email protected]
59 [email protected] "super" 63 [email protected]
64 [email protected] "super"
60 [email protected] "::" 65 [email protected] "::"
61 [email protected] 66 [email protected]
62 [email protected] 67 [email protected]
diff --git a/crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast b/crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast
index deadf56b4..01f601091 100644
--- a/crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast
+++ b/crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast
@@ -6,7 +6,8 @@ [email protected]
6 [email protected] 6 [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "::" 8 [email protected] "::"
9 [email protected] "self" 9 [email protected]
10 [email protected] "self"
10 [email protected] ";" 11 [email protected] ";"
11 [email protected] "\n" 12 [email protected] "\n"
12 [email protected] 13 [email protected]
@@ -20,7 +21,8 @@ [email protected]
20 [email protected] "a" 21 [email protected] "a"
21 [email protected] "::" 22 [email protected] "::"
22 [email protected] 23 [email protected]
23 [email protected] "self" 24 [email protected]
25 [email protected] "self"
24 [email protected] ";" 26 [email protected] ";"
25 [email protected] "\n" 27 [email protected] "\n"
26error 6..10: The `self` keyword is only allowed as the first segment of a path 28error 6..10: The `self` keyword is only allowed as the first segment of a path
diff --git a/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast
index e872526d9..d3c5dde58 100644
--- a/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast
+++ b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast
@@ -6,7 +6,8 @@ [email protected]
6 [email protected] 6 [email protected]
7 [email protected] 7 [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "crate" 9 [email protected]
10 [email protected] "crate"
10 [email protected] "::" 11 [email protected] "::"
11 [email protected] ";" 12 [email protected] ";"
12 [email protected] "\n" 13 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rast b/crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rast
index f40500e38..970826739 100644
--- a/crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rast
@@ -11,7 +11,8 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] 12 [email protected]
13 [email protected] 13 [email protected]
14 [email protected] "crate" 14 [email protected]
15 [email protected] "crate"
15 [email protected] "::" 16 [email protected] "::"
16 [email protected] 17 [email protected]
17 [email protected] 18 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0052_path_type.rast b/crates/syntax/test_data/parser/inline/ok/0052_path_type.rast
index 9bc36bea7..46a103d5b 100644
--- a/crates/syntax/test_data/parser/inline/ok/0052_path_type.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0052_path_type.rast
@@ -42,7 +42,8 @@ [email protected]
42 [email protected] 42 [email protected]
43 [email protected] 43 [email protected]
44 [email protected] 44 [email protected]
45 [email protected] "self" 45 [email protected]
46 [email protected] "self"
46 [email protected] "::" 47 [email protected] "::"
47 [email protected] 48 [email protected]
48 [email protected] 49 [email protected]
@@ -61,7 +62,8 @@ [email protected]
61 [email protected] 62 [email protected]
62 [email protected] 63 [email protected]
63 [email protected] 64 [email protected]
64 [email protected] "super" 65 [email protected]
66 [email protected] "super"
65 [email protected] "::" 67 [email protected] "::"
66 [email protected] 68 [email protected]
67 [email protected] 69 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rast b/crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rast
index e4fb32de1..583dcac7e 100644
--- a/crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rast
@@ -43,7 +43,8 @@ [email protected]
43 [email protected] 43 [email protected]
44 [email protected] 44 [email protected]
45 [email protected] 45 [email protected]
46 [email protected] "super" 46 [email protected]
47 [email protected] "super"
47 [email protected] "::" 48 [email protected] "::"
48 [email protected] 49 [email protected]
49 [email protected] 50 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0067_crate_path.rast b/crates/syntax/test_data/parser/inline/ok/0067_crate_path.rast
index 702f2e0b0..87c0c48dc 100644
--- a/crates/syntax/test_data/parser/inline/ok/0067_crate_path.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0067_crate_path.rast
@@ -6,7 +6,8 @@ [email protected]
6 [email protected] 6 [email protected]
7 [email protected] 7 [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "crate" 9 [email protected]
10 [email protected] "crate"
10 [email protected] "::" 11 [email protected] "::"
11 [email protected] 12 [email protected]
12 [email protected] 13 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast b/crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast
index c4c5bc51e..192a9cca6 100644
--- a/crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast
@@ -5,7 +5,8 @@ [email protected]
5 [email protected] 5 [email protected]
6 [email protected] 6 [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "crate" 8 [email protected]
9 [email protected] "crate"
9 [email protected] "::" 10 [email protected] "::"
10 [email protected] 11 [email protected]
11 [email protected] "{" 12 [email protected] "{"
@@ -23,7 +24,8 @@ [email protected]
23 [email protected] 24 [email protected]
24 [email protected] 25 [email protected]
25 [email protected] 26 [email protected]
26 [email protected] "self" 27 [email protected]
28 [email protected] "self"
27 [email protected] "::" 29 [email protected] "::"
28 [email protected] 30 [email protected]
29 [email protected] "{" 31 [email protected] "{"
diff --git a/crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rast b/crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rast
index f3d4ad72c..3016a6574 100644
--- a/crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rast
@@ -30,7 +30,8 @@ [email protected]
30 [email protected] 30 [email protected]
31 [email protected] 31 [email protected]
32 [email protected] 32 [email protected]
33 [email protected] "crate" 33 [email protected]
34 [email protected] "crate"
34 [email protected] "::" 35 [email protected] "::"
35 [email protected] 36 [email protected]
36 [email protected] 37 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast b/crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast
index aa4d7a784..0fed2d311 100644
--- a/crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast
@@ -17,7 +17,8 @@ [email protected]
17 [email protected] 17 [email protected]
18 [email protected] 18 [email protected]
19 [email protected] 19 [email protected]
20 [email protected] "crate" 20 [email protected]
21 [email protected] "crate"
21 [email protected] "::" 22 [email protected] "::"
22 [email protected] 23 [email protected]
23 [email protected] 24 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast b/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast
index c204f0e2d..a5ee07499 100644
--- a/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast
@@ -16,7 +16,8 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] 17 [email protected]
18 [email protected] 18 [email protected]
19 [email protected] "super" 19 [email protected]
20 [email protected] "super"
20 [email protected] "::" 21 [email protected] "::"
21 [email protected] 22 [email protected]
22 [email protected] 23 [email protected]
@@ -42,7 +43,8 @@ [email protected]
42 [email protected] 43 [email protected]
43 [email protected] 44 [email protected]
44 [email protected] 45 [email protected]
45 [email protected] "crate" 46 [email protected]
47 [email protected] "crate"
46 [email protected] "::" 48 [email protected] "::"
47 [email protected] 49 [email protected]
48 [email protected] 50 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rast b/crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rast
new file mode 100644
index 000000000..05fc90743
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rast
@@ -0,0 +1,28 @@
1[email protected]
2 [email protected]
3 [email protected] "fn"
4 [email protected] " "
5 [email protected]
6 [email protected] "foo"
7 [email protected]
8 [email protected] "("
9 [email protected] ")"
10 [email protected] " "
11 [email protected]
12 [email protected] "{"
13 [email protected] "\n "
14 [email protected]
15 [email protected]
16 [email protected] "yield"
17 [email protected] ";"
18 [email protected] "\n "
19 [email protected]
20 [email protected]
21 [email protected] "yield"
22 [email protected] " "
23 [email protected]
24 [email protected] "1"
25 [email protected] ";"
26 [email protected] "\n"
27 [email protected] "}"
28 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rs b/crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rs
new file mode 100644
index 000000000..596e221f7
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rs
@@ -0,0 +1,4 @@
1fn foo() {
2 yield;
3 yield 1;
4}
diff --git a/crates/syntax/test_data/parser/ok/0013_use_path_self_super.rast b/crates/syntax/test_data/parser/ok/0013_use_path_self_super.rast
index 66ab13660..dba74e222 100644
--- a/crates/syntax/test_data/parser/ok/0013_use_path_self_super.rast
+++ b/crates/syntax/test_data/parser/ok/0013_use_path_self_super.rast
@@ -6,7 +6,8 @@ [email protected]
6 [email protected] 6 [email protected]
7 [email protected] 7 [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "self" 9 [email protected]
10 [email protected] "self"
10 [email protected] "::" 11 [email protected] "::"
11 [email protected] 12 [email protected]
12 [email protected] 13 [email protected]
@@ -21,10 +22,12 @@ [email protected]
21 [email protected] 22 [email protected]
22 [email protected] 23 [email protected]
23 [email protected] 24 [email protected]
24 [email protected] "super" 25 [email protected]
26 [email protected] "super"
25 [email protected] "::" 27 [email protected] "::"
26 [email protected] 28 [email protected]
27 [email protected] "super" 29 [email protected]
30 [email protected] "super"
28 [email protected] "::" 31 [email protected] "::"
29 [email protected] 32 [email protected]
30 [email protected] 33 [email protected]
diff --git a/crates/syntax/test_data/parser/ok/0020_type_param_bounds.rast b/crates/syntax/test_data/parser/ok/0020_type_param_bounds.rast
index 0612a71de..21c564a20 100644
--- a/crates/syntax/test_data/parser/ok/0020_type_param_bounds.rast
+++ b/crates/syntax/test_data/parser/ok/0020_type_param_bounds.rast
@@ -187,7 +187,8 @@ [email protected]
187 [email protected] 187 [email protected]
188 [email protected] 188 [email protected]
189 [email protected] 189 [email protected]
190 [email protected] "self" 190 [email protected]
191 [email protected] "self"
191 [email protected] "::" 192 [email protected] "::"
192 [email protected] 193 [email protected]
193 [email protected] 194 [email protected]
diff --git a/crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rast b/crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rast
index 5ad8c570d..a0a5ca7f5 100644
--- a/crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rast
+++ b/crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rast
@@ -25,7 +25,8 @@ [email protected]
25 [email protected] 25 [email protected]
26 [email protected] 26 [email protected]
27 [email protected] 27 [email protected]
28 [email protected] "crate" 28 [email protected]
29 [email protected] "crate"
29 [email protected] "::" 30 [email protected] "::"
30 [email protected] 31 [email protected]
31 [email protected] 32 [email protected]