aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-11 18:33:20 +0100
committerGitHub <[email protected]>2020-06-11 18:33:20 +0100
commit36353bb1827dbd2efcde2d18c8598c4cc5e2e296 (patch)
tree5b08ffc573918a2210abbb5b06ec523770cbab1b /crates/ra_syntax/src
parentbd61ad756cc0a7bfeaa5dae81ac5ab50a2e71697 (diff)
parent8622e4cc1b79f5d23b8a2c6610d749f5b987ea7e (diff)
Merge #4833
4833: Separating parsing of `for` in predicates and types r=matklad a=matthewjasper We now correctly accept `for<'a> (&'a F): Fn(&'a str)` in a where clause and correctly reject `for<'a> &'a u32` as a type. Co-authored-by: Matthew Jasper <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs6
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs2
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}
2053impl ast::TypeBoundsOwner for WherePred {} 2053impl ast::TypeBoundsOwner for WherePred {}
2054impl WherePred { 2054impl 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 }