diff options
author | Matthew Jasper <[email protected]> | 2020-06-10 11:30:48 +0100 |
---|---|---|
committer | Matthew Jasper <[email protected]> | 2020-06-10 11:30:58 +0100 |
commit | 506e1ddbfa5213f254923da9bbf0efddc6f1fc34 (patch) | |
tree | 2c220370c38a8a79a6d9b07d0fe184db0d827e1d /crates/ra_syntax/src | |
parent | 560b98bc505be6ff70876df661e4055e1b38a78c (diff) |
Separating parsing of `for` in predicates and types
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index eddc807d5..9d02aeef3 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -285,6 +285,8 @@ where | |||
285 | let pred = predicates.next().unwrap(); | 285 | let pred = predicates.next().unwrap(); |
286 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 286 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
287 | 287 | ||
288 | assert!(pred.for_token().is_none()); | ||
289 | assert!(pred.type_param_list().is_none()); | ||
288 | assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); | 290 | assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); |
289 | assert_bound("Clone", bounds.next()); | 291 | assert_bound("Clone", bounds.next()); |
290 | assert_bound("Copy", bounds.next()); | 292 | assert_bound("Copy", bounds.next()); |
@@ -322,6 +324,8 @@ where | |||
322 | let pred = predicates.next().unwrap(); | 324 | let pred = predicates.next().unwrap(); |
323 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 325 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
324 | 326 | ||
325 | assert_eq!("for<'a> F", pred.type_ref().unwrap().syntax().text().to_string()); | 327 | assert!(pred.for_token().is_some()); |
328 | assert_eq!("<'a>", pred.type_param_list().unwrap().syntax().text().to_string()); | ||
329 | assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); | ||
326 | assert_bound("Fn(&'a str)", bounds.next()); | 330 | assert_bound("Fn(&'a str)", bounds.next()); |
327 | } | 331 | } |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index cb430ca01..40081ebb1 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -2052,6 +2052,8 @@ pub struct WherePred { | |||
2052 | } | 2052 | } |
2053 | impl ast::TypeBoundsOwner for WherePred {} | 2053 | impl ast::TypeBoundsOwner for WherePred {} |
2054 | impl WherePred { | 2054 | impl WherePred { |
2055 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | ||
2056 | pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } | ||
2055 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | 2057 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { |
2056 | support::token(&self.syntax, T![lifetime]) | 2058 | support::token(&self.syntax, T![lifetime]) |
2057 | } | 2059 | } |