mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-27 20:35:09 +00:00
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 <mjjasper1@gmail.com>
This commit is contained in:
commit
36353bb182
14 changed files with 843 additions and 291 deletions
|
@ -191,10 +191,14 @@ fn where_predicate(p: &mut Parser) {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// test where_pred_for
|
// test where_pred_for
|
||||||
// fn test<F>()
|
// fn for_trait<F>()
|
||||||
// where
|
// where
|
||||||
// for<'a> F: Fn(&'a str)
|
// for<'a> F: Fn(&'a str)
|
||||||
// { }
|
// { }
|
||||||
|
if p.at(T![for]) {
|
||||||
|
types::for_binder(p);
|
||||||
|
}
|
||||||
|
|
||||||
types::type_(p);
|
types::type_(p);
|
||||||
|
|
||||||
if p.at(T![:]) {
|
if p.at(T![:]) {
|
||||||
|
|
|
@ -216,19 +216,21 @@ pub(super) fn for_binder(p: &mut Parser) {
|
||||||
|
|
||||||
// test for_type
|
// test for_type
|
||||||
// type A = for<'a> fn() -> ();
|
// type A = for<'a> fn() -> ();
|
||||||
// fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {}
|
// type B = for<'a> unsafe extern "C" fn(&'a ()) -> ();
|
||||||
// fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {}
|
// type Obj = for<'a> PartialEq<&'a i32>;
|
||||||
// fn baz<T>(_t: &T) where for<'a> <&'a T as Baz>::Foo: Iterator {}
|
|
||||||
pub(super) fn for_type(p: &mut Parser) {
|
pub(super) fn for_type(p: &mut Parser) {
|
||||||
assert!(p.at(T![for]));
|
assert!(p.at(T![for]));
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
for_binder(p);
|
for_binder(p);
|
||||||
match p.current() {
|
match p.current() {
|
||||||
T![fn] | T![unsafe] | T![extern] => fn_pointer_type(p),
|
T![fn] | T![unsafe] | T![extern] => {}
|
||||||
T![&] => reference_type(p),
|
// OK: legacy trait object format
|
||||||
_ if paths::is_path_start(p) => path_type_(p, false),
|
_ if paths::is_use_path_start(p) => {}
|
||||||
_ => p.error("expected a path"),
|
_ => {
|
||||||
|
p.error("expected a function pointer or path");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
type_no_bounds(p);
|
||||||
m.complete(p, FOR_TYPE);
|
m.complete(p, FOR_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,8 @@ where
|
||||||
let pred = predicates.next().unwrap();
|
let pred = predicates.next().unwrap();
|
||||||
let mut bounds = pred.type_bound_list().unwrap().bounds();
|
let mut bounds = pred.type_bound_list().unwrap().bounds();
|
||||||
|
|
||||||
|
assert!(pred.for_token().is_none());
|
||||||
|
assert!(pred.type_param_list().is_none());
|
||||||
assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string());
|
assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string());
|
||||||
assert_bound("Clone", bounds.next());
|
assert_bound("Clone", bounds.next());
|
||||||
assert_bound("Copy", bounds.next());
|
assert_bound("Copy", bounds.next());
|
||||||
|
@ -322,6 +324,8 @@ where
|
||||||
let pred = predicates.next().unwrap();
|
let pred = predicates.next().unwrap();
|
||||||
let mut bounds = pred.type_bound_list().unwrap().bounds();
|
let mut bounds = pred.type_bound_list().unwrap().bounds();
|
||||||
|
|
||||||
assert_eq!("for<'a> F", pred.type_ref().unwrap().syntax().text().to_string());
|
assert!(pred.for_token().is_some());
|
||||||
|
assert_eq!("<'a>", pred.type_param_list().unwrap().syntax().text().to_string());
|
||||||
|
assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string());
|
||||||
assert_bound("Fn(&'a str)", bounds.next());
|
assert_bound("Fn(&'a str)", bounds.next());
|
||||||
}
|
}
|
||||||
|
|
|
@ -2052,6 +2052,8 @@ pub struct WherePred {
|
||||||
}
|
}
|
||||||
impl ast::TypeBoundsOwner for WherePred {}
|
impl ast::TypeBoundsOwner for WherePred {}
|
||||||
impl WherePred {
|
impl WherePred {
|
||||||
|
pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
|
||||||
|
pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
|
||||||
pub fn lifetime_token(&self) -> Option<SyntaxToken> {
|
pub fn lifetime_token(&self) -> Option<SyntaxToken> {
|
||||||
support::token(&self.syntax, T![lifetime])
|
support::token(&self.syntax, T![lifetime])
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ SOURCE_FILE@0..30
|
||||||
WHERE_KW@13..18 "where"
|
WHERE_KW@13..18 "where"
|
||||||
WHITESPACE@18..19 " "
|
WHITESPACE@18..19 " "
|
||||||
WHERE_PRED@19..26
|
WHERE_PRED@19..26
|
||||||
FOR_TYPE@19..26
|
|
||||||
FOR_KW@19..22 "for"
|
FOR_KW@19..22 "for"
|
||||||
TYPE_PARAM_LIST@22..26
|
TYPE_PARAM_LIST@22..26
|
||||||
L_ANGLE@22..23 "<"
|
L_ANGLE@22..23 "<"
|
||||||
|
@ -24,5 +23,5 @@ SOURCE_FILE@0..30
|
||||||
L_CURLY@27..28 "{"
|
L_CURLY@27..28 "{"
|
||||||
R_CURLY@28..29 "}"
|
R_CURLY@28..29 "}"
|
||||||
WHITESPACE@29..30 "\n"
|
WHITESPACE@29..30 "\n"
|
||||||
error 26..26: expected a path
|
error 26..26: expected type
|
||||||
error 26..26: expected colon
|
error 26..26: expected colon
|
||||||
|
|
|
@ -0,0 +1,240 @@
|
||||||
|
SOURCE_FILE@0..239
|
||||||
|
TYPE_ALIAS_DEF@0..30
|
||||||
|
TYPE_KW@0..4 "type"
|
||||||
|
WHITESPACE@4..5 " "
|
||||||
|
NAME@5..11
|
||||||
|
IDENT@5..11 "ForRef"
|
||||||
|
WHITESPACE@11..12 " "
|
||||||
|
EQ@12..13 "="
|
||||||
|
WHITESPACE@13..14 " "
|
||||||
|
FOR_TYPE@14..29
|
||||||
|
FOR_KW@14..17 "for"
|
||||||
|
TYPE_PARAM_LIST@17..21
|
||||||
|
L_ANGLE@17..18 "<"
|
||||||
|
LIFETIME_PARAM@18..20
|
||||||
|
LIFETIME@18..20 "\'a"
|
||||||
|
R_ANGLE@20..21 ">"
|
||||||
|
WHITESPACE@21..22 " "
|
||||||
|
REFERENCE_TYPE@22..29
|
||||||
|
AMP@22..23 "&"
|
||||||
|
LIFETIME@23..25 "\'a"
|
||||||
|
WHITESPACE@25..26 " "
|
||||||
|
PATH_TYPE@26..29
|
||||||
|
PATH@26..29
|
||||||
|
PATH_SEGMENT@26..29
|
||||||
|
NAME_REF@26..29
|
||||||
|
IDENT@26..29 "u32"
|
||||||
|
SEMICOLON@29..30 ";"
|
||||||
|
WHITESPACE@30..31 "\n"
|
||||||
|
TYPE_ALIAS_DEF@31..64
|
||||||
|
TYPE_KW@31..35 "type"
|
||||||
|
WHITESPACE@35..36 " "
|
||||||
|
NAME@36..42
|
||||||
|
IDENT@36..42 "ForTup"
|
||||||
|
WHITESPACE@42..43 " "
|
||||||
|
EQ@43..44 "="
|
||||||
|
WHITESPACE@44..45 " "
|
||||||
|
FOR_TYPE@45..63
|
||||||
|
FOR_KW@45..48 "for"
|
||||||
|
TYPE_PARAM_LIST@48..52
|
||||||
|
L_ANGLE@48..49 "<"
|
||||||
|
LIFETIME_PARAM@49..51
|
||||||
|
LIFETIME@49..51 "\'a"
|
||||||
|
R_ANGLE@51..52 ">"
|
||||||
|
WHITESPACE@52..53 " "
|
||||||
|
TUPLE_TYPE@53..63
|
||||||
|
L_PAREN@53..54 "("
|
||||||
|
REFERENCE_TYPE@54..61
|
||||||
|
AMP@54..55 "&"
|
||||||
|
LIFETIME@55..57 "\'a"
|
||||||
|
WHITESPACE@57..58 " "
|
||||||
|
PATH_TYPE@58..61
|
||||||
|
PATH@58..61
|
||||||
|
PATH_SEGMENT@58..61
|
||||||
|
NAME_REF@58..61
|
||||||
|
IDENT@58..61 "u32"
|
||||||
|
COMMA@61..62 ","
|
||||||
|
R_PAREN@62..63 ")"
|
||||||
|
SEMICOLON@63..64 ";"
|
||||||
|
WHITESPACE@64..65 "\n"
|
||||||
|
TYPE_ALIAS_DEF@65..95
|
||||||
|
TYPE_KW@65..69 "type"
|
||||||
|
WHITESPACE@69..70 " "
|
||||||
|
NAME@70..78
|
||||||
|
IDENT@70..78 "ForSlice"
|
||||||
|
WHITESPACE@78..79 " "
|
||||||
|
EQ@79..80 "="
|
||||||
|
WHITESPACE@80..81 " "
|
||||||
|
FOR_TYPE@81..94
|
||||||
|
FOR_KW@81..84 "for"
|
||||||
|
TYPE_PARAM_LIST@84..88
|
||||||
|
L_ANGLE@84..85 "<"
|
||||||
|
LIFETIME_PARAM@85..87
|
||||||
|
LIFETIME@85..87 "\'a"
|
||||||
|
R_ANGLE@87..88 ">"
|
||||||
|
WHITESPACE@88..89 " "
|
||||||
|
SLICE_TYPE@89..94
|
||||||
|
L_BRACK@89..90 "["
|
||||||
|
PATH_TYPE@90..93
|
||||||
|
PATH@90..93
|
||||||
|
PATH_SEGMENT@90..93
|
||||||
|
NAME_REF@90..93
|
||||||
|
IDENT@90..93 "u32"
|
||||||
|
R_BRACK@93..94 "]"
|
||||||
|
SEMICOLON@94..95 ";"
|
||||||
|
WHITESPACE@95..96 "\n"
|
||||||
|
TYPE_ALIAS_DEF@96..149
|
||||||
|
TYPE_KW@96..100 "type"
|
||||||
|
WHITESPACE@100..101 " "
|
||||||
|
NAME@101..109
|
||||||
|
IDENT@101..109 "ForForFn"
|
||||||
|
WHITESPACE@109..110 " "
|
||||||
|
EQ@110..111 "="
|
||||||
|
WHITESPACE@111..112 " "
|
||||||
|
FOR_TYPE@112..148
|
||||||
|
FOR_KW@112..115 "for"
|
||||||
|
TYPE_PARAM_LIST@115..119
|
||||||
|
L_ANGLE@115..116 "<"
|
||||||
|
LIFETIME_PARAM@116..118
|
||||||
|
LIFETIME@116..118 "\'a"
|
||||||
|
R_ANGLE@118..119 ">"
|
||||||
|
WHITESPACE@119..120 " "
|
||||||
|
FOR_TYPE@120..148
|
||||||
|
FOR_KW@120..123 "for"
|
||||||
|
TYPE_PARAM_LIST@123..127
|
||||||
|
L_ANGLE@123..124 "<"
|
||||||
|
LIFETIME_PARAM@124..126
|
||||||
|
LIFETIME@124..126 "\'b"
|
||||||
|
R_ANGLE@126..127 ">"
|
||||||
|
WHITESPACE@127..128 " "
|
||||||
|
FN_POINTER_TYPE@128..148
|
||||||
|
FN_KW@128..130 "fn"
|
||||||
|
PARAM_LIST@130..148
|
||||||
|
L_PAREN@130..131 "("
|
||||||
|
PARAM@131..138
|
||||||
|
REFERENCE_TYPE@131..138
|
||||||
|
AMP@131..132 "&"
|
||||||
|
LIFETIME@132..134 "\'a"
|
||||||
|
WHITESPACE@134..135 " "
|
||||||
|
PATH_TYPE@135..138
|
||||||
|
PATH@135..138
|
||||||
|
PATH_SEGMENT@135..138
|
||||||
|
NAME_REF@135..138
|
||||||
|
IDENT@135..138 "i32"
|
||||||
|
COMMA@138..139 ","
|
||||||
|
WHITESPACE@139..140 " "
|
||||||
|
PARAM@140..147
|
||||||
|
REFERENCE_TYPE@140..147
|
||||||
|
AMP@140..141 "&"
|
||||||
|
LIFETIME@141..143 "\'b"
|
||||||
|
WHITESPACE@143..144 " "
|
||||||
|
PATH_TYPE@144..147
|
||||||
|
PATH@144..147
|
||||||
|
PATH_SEGMENT@144..147
|
||||||
|
NAME_REF@144..147
|
||||||
|
IDENT@144..147 "i32"
|
||||||
|
R_PAREN@147..148 ")"
|
||||||
|
SEMICOLON@148..149 ";"
|
||||||
|
WHITESPACE@149..150 "\n"
|
||||||
|
FN_DEF@150..238
|
||||||
|
FN_KW@150..152 "fn"
|
||||||
|
WHITESPACE@152..153 " "
|
||||||
|
NAME@153..164
|
||||||
|
IDENT@153..164 "for_for_for"
|
||||||
|
TYPE_PARAM_LIST@164..167
|
||||||
|
L_ANGLE@164..165 "<"
|
||||||
|
TYPE_PARAM@165..166
|
||||||
|
NAME@165..166
|
||||||
|
IDENT@165..166 "T"
|
||||||
|
R_ANGLE@166..167 ">"
|
||||||
|
PARAM_LIST@167..169
|
||||||
|
L_PAREN@167..168 "("
|
||||||
|
R_PAREN@168..169 ")"
|
||||||
|
WHITESPACE@169..170 "\n"
|
||||||
|
WHERE_CLAUSE@170..234
|
||||||
|
WHERE_KW@170..175 "where"
|
||||||
|
WHITESPACE@175..180 "\n "
|
||||||
|
WHERE_PRED@180..233
|
||||||
|
FOR_KW@180..183 "for"
|
||||||
|
TYPE_PARAM_LIST@183..187
|
||||||
|
L_ANGLE@183..184 "<"
|
||||||
|
LIFETIME_PARAM@184..186
|
||||||
|
LIFETIME@184..186 "\'a"
|
||||||
|
R_ANGLE@186..187 ">"
|
||||||
|
WHITESPACE@187..188 " "
|
||||||
|
FOR_TYPE@188..227
|
||||||
|
FOR_KW@188..191 "for"
|
||||||
|
TYPE_PARAM_LIST@191..195
|
||||||
|
L_ANGLE@191..192 "<"
|
||||||
|
LIFETIME_PARAM@192..194
|
||||||
|
LIFETIME@192..194 "\'b"
|
||||||
|
R_ANGLE@194..195 ">"
|
||||||
|
WHITESPACE@195..196 " "
|
||||||
|
FOR_TYPE@196..227
|
||||||
|
FOR_KW@196..199 "for"
|
||||||
|
TYPE_PARAM_LIST@199..203
|
||||||
|
L_ANGLE@199..200 "<"
|
||||||
|
LIFETIME_PARAM@200..202
|
||||||
|
LIFETIME@200..202 "\'c"
|
||||||
|
R_ANGLE@202..203 ">"
|
||||||
|
WHITESPACE@203..204 " "
|
||||||
|
FN_POINTER_TYPE@204..227
|
||||||
|
FN_KW@204..206 "fn"
|
||||||
|
PARAM_LIST@206..227
|
||||||
|
L_PAREN@206..207 "("
|
||||||
|
PARAM@207..212
|
||||||
|
REFERENCE_TYPE@207..212
|
||||||
|
AMP@207..208 "&"
|
||||||
|
LIFETIME@208..210 "\'a"
|
||||||
|
WHITESPACE@210..211 " "
|
||||||
|
PATH_TYPE@211..212
|
||||||
|
PATH@211..212
|
||||||
|
PATH_SEGMENT@211..212
|
||||||
|
NAME_REF@211..212
|
||||||
|
IDENT@211..212 "T"
|
||||||
|
COMMA@212..213 ","
|
||||||
|
WHITESPACE@213..214 " "
|
||||||
|
PARAM@214..219
|
||||||
|
REFERENCE_TYPE@214..219
|
||||||
|
AMP@214..215 "&"
|
||||||
|
LIFETIME@215..217 "\'b"
|
||||||
|
WHITESPACE@217..218 " "
|
||||||
|
PATH_TYPE@218..219
|
||||||
|
PATH@218..219
|
||||||
|
PATH_SEGMENT@218..219
|
||||||
|
NAME_REF@218..219
|
||||||
|
IDENT@218..219 "T"
|
||||||
|
COMMA@219..220 ","
|
||||||
|
WHITESPACE@220..221 " "
|
||||||
|
PARAM@221..226
|
||||||
|
REFERENCE_TYPE@221..226
|
||||||
|
AMP@221..222 "&"
|
||||||
|
LIFETIME@222..224 "\'c"
|
||||||
|
WHITESPACE@224..225 " "
|
||||||
|
PATH_TYPE@225..226
|
||||||
|
PATH@225..226
|
||||||
|
PATH_SEGMENT@225..226
|
||||||
|
NAME_REF@225..226
|
||||||
|
IDENT@225..226 "T"
|
||||||
|
R_PAREN@226..227 ")"
|
||||||
|
COLON@227..228 ":"
|
||||||
|
WHITESPACE@228..229 " "
|
||||||
|
TYPE_BOUND_LIST@229..233
|
||||||
|
TYPE_BOUND@229..233
|
||||||
|
PATH_TYPE@229..233
|
||||||
|
PATH@229..233
|
||||||
|
PATH_SEGMENT@229..233
|
||||||
|
NAME_REF@229..233
|
||||||
|
IDENT@229..233 "Copy"
|
||||||
|
COMMA@233..234 ","
|
||||||
|
WHITESPACE@234..235 "\n"
|
||||||
|
BLOCK_EXPR@235..238
|
||||||
|
L_CURLY@235..236 "{"
|
||||||
|
WHITESPACE@236..237 "\n"
|
||||||
|
R_CURLY@237..238 "}"
|
||||||
|
WHITESPACE@238..239 "\n"
|
||||||
|
error 21..21: expected a function pointer or path
|
||||||
|
error 52..52: expected a function pointer or path
|
||||||
|
error 88..88: expected a function pointer or path
|
||||||
|
error 119..119: expected a function pointer or path
|
||||||
|
error 195..195: expected a function pointer or path
|
|
@ -0,0 +1,9 @@
|
||||||
|
type ForRef = for<'a> &'a u32;
|
||||||
|
type ForTup = for<'a> (&'a u32,);
|
||||||
|
type ForSlice = for<'a> [u32];
|
||||||
|
type ForForFn = for<'a> for<'b> fn(&'a i32, &'b i32);
|
||||||
|
fn for_for_for<T>()
|
||||||
|
where
|
||||||
|
for<'a> for<'b> for<'c> fn(&'a T, &'b T, &'c T): Copy,
|
||||||
|
{
|
||||||
|
}
|
|
@ -1,61 +1,60 @@
|
||||||
SOURCE_FILE@0..49
|
SOURCE_FILE@0..54
|
||||||
FN_DEF@0..48
|
FN_DEF@0..53
|
||||||
FN_KW@0..2 "fn"
|
FN_KW@0..2 "fn"
|
||||||
WHITESPACE@2..3 " "
|
WHITESPACE@2..3 " "
|
||||||
NAME@3..7
|
NAME@3..12
|
||||||
IDENT@3..7 "test"
|
IDENT@3..12 "for_trait"
|
||||||
TYPE_PARAM_LIST@7..10
|
TYPE_PARAM_LIST@12..15
|
||||||
L_ANGLE@7..8 "<"
|
L_ANGLE@12..13 "<"
|
||||||
TYPE_PARAM@8..9
|
TYPE_PARAM@13..14
|
||||||
NAME@8..9
|
NAME@13..14
|
||||||
IDENT@8..9 "F"
|
IDENT@13..14 "F"
|
||||||
R_ANGLE@9..10 ">"
|
R_ANGLE@14..15 ">"
|
||||||
PARAM_LIST@10..12
|
PARAM_LIST@15..17
|
||||||
L_PAREN@10..11 "("
|
L_PAREN@15..16 "("
|
||||||
R_PAREN@11..12 ")"
|
R_PAREN@16..17 ")"
|
||||||
WHITESPACE@12..13 "\n"
|
WHITESPACE@17..18 "\n"
|
||||||
WHERE_CLAUSE@13..44
|
WHERE_CLAUSE@18..49
|
||||||
WHERE_KW@13..18 "where"
|
WHERE_KW@18..23 "where"
|
||||||
WHITESPACE@18..22 "\n "
|
WHITESPACE@23..27 "\n "
|
||||||
WHERE_PRED@22..44
|
WHERE_PRED@27..49
|
||||||
FOR_TYPE@22..31
|
FOR_KW@27..30 "for"
|
||||||
FOR_KW@22..25 "for"
|
TYPE_PARAM_LIST@30..34
|
||||||
TYPE_PARAM_LIST@25..29
|
L_ANGLE@30..31 "<"
|
||||||
L_ANGLE@25..26 "<"
|
LIFETIME_PARAM@31..33
|
||||||
LIFETIME_PARAM@26..28
|
LIFETIME@31..33 "\'a"
|
||||||
LIFETIME@26..28 "\'a"
|
R_ANGLE@33..34 ">"
|
||||||
R_ANGLE@28..29 ">"
|
WHITESPACE@34..35 " "
|
||||||
WHITESPACE@29..30 " "
|
PATH_TYPE@35..36
|
||||||
PATH_TYPE@30..31
|
PATH@35..36
|
||||||
PATH@30..31
|
PATH_SEGMENT@35..36
|
||||||
PATH_SEGMENT@30..31
|
NAME_REF@35..36
|
||||||
NAME_REF@30..31
|
IDENT@35..36 "F"
|
||||||
IDENT@30..31 "F"
|
COLON@36..37 ":"
|
||||||
COLON@31..32 ":"
|
WHITESPACE@37..38 " "
|
||||||
WHITESPACE@32..33 " "
|
TYPE_BOUND_LIST@38..49
|
||||||
TYPE_BOUND_LIST@33..44
|
TYPE_BOUND@38..49
|
||||||
TYPE_BOUND@33..44
|
PATH_TYPE@38..49
|
||||||
PATH_TYPE@33..44
|
PATH@38..49
|
||||||
PATH@33..44
|
PATH_SEGMENT@38..49
|
||||||
PATH_SEGMENT@33..44
|
NAME_REF@38..40
|
||||||
NAME_REF@33..35
|
IDENT@38..40 "Fn"
|
||||||
IDENT@33..35 "Fn"
|
PARAM_LIST@40..49
|
||||||
PARAM_LIST@35..44
|
L_PAREN@40..41 "("
|
||||||
L_PAREN@35..36 "("
|
PARAM@41..48
|
||||||
PARAM@36..43
|
REFERENCE_TYPE@41..48
|
||||||
REFERENCE_TYPE@36..43
|
AMP@41..42 "&"
|
||||||
AMP@36..37 "&"
|
LIFETIME@42..44 "\'a"
|
||||||
LIFETIME@37..39 "\'a"
|
WHITESPACE@44..45 " "
|
||||||
WHITESPACE@39..40 " "
|
PATH_TYPE@45..48
|
||||||
PATH_TYPE@40..43
|
PATH@45..48
|
||||||
PATH@40..43
|
PATH_SEGMENT@45..48
|
||||||
PATH_SEGMENT@40..43
|
NAME_REF@45..48
|
||||||
NAME_REF@40..43
|
IDENT@45..48 "str"
|
||||||
IDENT@40..43 "str"
|
R_PAREN@48..49 ")"
|
||||||
R_PAREN@43..44 ")"
|
WHITESPACE@49..50 "\n"
|
||||||
WHITESPACE@44..45 "\n"
|
BLOCK_EXPR@50..53
|
||||||
BLOCK_EXPR@45..48
|
L_CURLY@50..51 "{"
|
||||||
L_CURLY@45..46 "{"
|
WHITESPACE@51..52 " "
|
||||||
WHITESPACE@46..47 " "
|
R_CURLY@52..53 "}"
|
||||||
R_CURLY@47..48 "}"
|
WHITESPACE@53..54 "\n"
|
||||||
WHITESPACE@48..49 "\n"
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
fn test<F>()
|
fn for_trait<F>()
|
||||||
where
|
where
|
||||||
for<'a> F: Fn(&'a str)
|
for<'a> F: Fn(&'a str)
|
||||||
{ }
|
{ }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
SOURCE_FILE@0..200
|
SOURCE_FILE@0..121
|
||||||
TYPE_ALIAS_DEF@0..28
|
TYPE_ALIAS_DEF@0..28
|
||||||
TYPE_KW@0..4 "type"
|
TYPE_KW@0..4 "type"
|
||||||
WHITESPACE@4..5 " "
|
WHITESPACE@4..5 " "
|
||||||
|
@ -29,212 +29,84 @@ SOURCE_FILE@0..200
|
||||||
R_PAREN@26..27 ")"
|
R_PAREN@26..27 ")"
|
||||||
SEMICOLON@27..28 ";"
|
SEMICOLON@27..28 ";"
|
||||||
WHITESPACE@28..29 "\n"
|
WHITESPACE@28..29 "\n"
|
||||||
FN_DEF@29..79
|
TYPE_ALIAS_DEF@29..81
|
||||||
FN_KW@29..31 "fn"
|
TYPE_KW@29..33 "type"
|
||||||
WHITESPACE@31..32 " "
|
WHITESPACE@33..34 " "
|
||||||
NAME@32..35
|
NAME@34..35
|
||||||
IDENT@32..35 "foo"
|
IDENT@34..35 "B"
|
||||||
TYPE_PARAM_LIST@35..38
|
WHITESPACE@35..36 " "
|
||||||
L_ANGLE@35..36 "<"
|
EQ@36..37 "="
|
||||||
TYPE_PARAM@36..37
|
WHITESPACE@37..38 " "
|
||||||
NAME@36..37
|
FOR_TYPE@38..80
|
||||||
IDENT@36..37 "T"
|
FOR_KW@38..41 "for"
|
||||||
R_ANGLE@37..38 ">"
|
TYPE_PARAM_LIST@41..45
|
||||||
PARAM_LIST@38..46
|
L_ANGLE@41..42 "<"
|
||||||
L_PAREN@38..39 "("
|
LIFETIME_PARAM@42..44
|
||||||
PARAM@39..45
|
LIFETIME@42..44 "\'a"
|
||||||
BIND_PAT@39..41
|
R_ANGLE@44..45 ">"
|
||||||
NAME@39..41
|
WHITESPACE@45..46 " "
|
||||||
IDENT@39..41 "_t"
|
FN_POINTER_TYPE@46..80
|
||||||
COLON@41..42 ":"
|
UNSAFE_KW@46..52 "unsafe"
|
||||||
WHITESPACE@42..43 " "
|
|
||||||
REFERENCE_TYPE@43..45
|
|
||||||
AMP@43..44 "&"
|
|
||||||
PATH_TYPE@44..45
|
|
||||||
PATH@44..45
|
|
||||||
PATH_SEGMENT@44..45
|
|
||||||
NAME_REF@44..45
|
|
||||||
IDENT@44..45 "T"
|
|
||||||
R_PAREN@45..46 ")"
|
|
||||||
WHITESPACE@46..47 " "
|
|
||||||
WHERE_CLAUSE@47..76
|
|
||||||
WHERE_KW@47..52 "where"
|
|
||||||
WHITESPACE@52..53 " "
|
WHITESPACE@52..53 " "
|
||||||
WHERE_PRED@53..76
|
ABI@53..63
|
||||||
FOR_TYPE@53..66
|
EXTERN_KW@53..59 "extern"
|
||||||
FOR_KW@53..56 "for"
|
WHITESPACE@59..60 " "
|
||||||
TYPE_PARAM_LIST@56..60
|
STRING@60..63 "\"C\""
|
||||||
L_ANGLE@56..57 "<"
|
WHITESPACE@63..64 " "
|
||||||
LIFETIME_PARAM@57..59
|
FN_KW@64..66 "fn"
|
||||||
LIFETIME@57..59 "\'a"
|
PARAM_LIST@66..74
|
||||||
R_ANGLE@59..60 ">"
|
L_PAREN@66..67 "("
|
||||||
WHITESPACE@60..61 " "
|
PARAM@67..73
|
||||||
REFERENCE_TYPE@61..66
|
REFERENCE_TYPE@67..73
|
||||||
AMP@61..62 "&"
|
AMP@67..68 "&"
|
||||||
LIFETIME@62..64 "\'a"
|
LIFETIME@68..70 "\'a"
|
||||||
WHITESPACE@64..65 " "
|
WHITESPACE@70..71 " "
|
||||||
PATH_TYPE@65..66
|
TUPLE_TYPE@71..73
|
||||||
PATH@65..66
|
L_PAREN@71..72 "("
|
||||||
PATH_SEGMENT@65..66
|
R_PAREN@72..73 ")"
|
||||||
NAME_REF@65..66
|
R_PAREN@73..74 ")"
|
||||||
IDENT@65..66 "T"
|
WHITESPACE@74..75 " "
|
||||||
COLON@66..67 ":"
|
RET_TYPE@75..80
|
||||||
WHITESPACE@67..68 " "
|
THIN_ARROW@75..77 "->"
|
||||||
TYPE_BOUND_LIST@68..76
|
WHITESPACE@77..78 " "
|
||||||
TYPE_BOUND@68..76
|
TUPLE_TYPE@78..80
|
||||||
PATH_TYPE@68..76
|
L_PAREN@78..79 "("
|
||||||
PATH@68..76
|
R_PAREN@79..80 ")"
|
||||||
PATH_SEGMENT@68..76
|
SEMICOLON@80..81 ";"
|
||||||
NAME_REF@68..76
|
WHITESPACE@81..82 "\n"
|
||||||
IDENT@68..76 "Iterator"
|
TYPE_ALIAS_DEF@82..120
|
||||||
WHITESPACE@76..77 " "
|
TYPE_KW@82..86 "type"
|
||||||
BLOCK_EXPR@77..79
|
WHITESPACE@86..87 " "
|
||||||
L_CURLY@77..78 "{"
|
NAME@87..90
|
||||||
R_CURLY@78..79 "}"
|
IDENT@87..90 "Obj"
|
||||||
WHITESPACE@79..80 "\n"
|
WHITESPACE@90..91 " "
|
||||||
FN_DEF@80..134
|
EQ@91..92 "="
|
||||||
FN_KW@80..82 "fn"
|
WHITESPACE@92..93 " "
|
||||||
WHITESPACE@82..83 " "
|
FOR_TYPE@93..119
|
||||||
NAME@83..86
|
FOR_KW@93..96 "for"
|
||||||
IDENT@83..86 "bar"
|
TYPE_PARAM_LIST@96..100
|
||||||
TYPE_PARAM_LIST@86..89
|
L_ANGLE@96..97 "<"
|
||||||
L_ANGLE@86..87 "<"
|
LIFETIME_PARAM@97..99
|
||||||
TYPE_PARAM@87..88
|
LIFETIME@97..99 "\'a"
|
||||||
NAME@87..88
|
R_ANGLE@99..100 ">"
|
||||||
IDENT@87..88 "T"
|
WHITESPACE@100..101 " "
|
||||||
R_ANGLE@88..89 ">"
|
PATH_TYPE@101..119
|
||||||
PARAM_LIST@89..97
|
PATH@101..119
|
||||||
L_PAREN@89..90 "("
|
PATH_SEGMENT@101..119
|
||||||
PARAM@90..96
|
NAME_REF@101..110
|
||||||
BIND_PAT@90..92
|
IDENT@101..110 "PartialEq"
|
||||||
NAME@90..92
|
TYPE_ARG_LIST@110..119
|
||||||
IDENT@90..92 "_t"
|
L_ANGLE@110..111 "<"
|
||||||
COLON@92..93 ":"
|
TYPE_ARG@111..118
|
||||||
WHITESPACE@93..94 " "
|
REFERENCE_TYPE@111..118
|
||||||
REFERENCE_TYPE@94..96
|
AMP@111..112 "&"
|
||||||
AMP@94..95 "&"
|
LIFETIME@112..114 "\'a"
|
||||||
PATH_TYPE@95..96
|
WHITESPACE@114..115 " "
|
||||||
PATH@95..96
|
PATH_TYPE@115..118
|
||||||
PATH_SEGMENT@95..96
|
PATH@115..118
|
||||||
NAME_REF@95..96
|
PATH_SEGMENT@115..118
|
||||||
IDENT@95..96 "T"
|
NAME_REF@115..118
|
||||||
R_PAREN@96..97 ")"
|
IDENT@115..118 "i32"
|
||||||
WHITESPACE@97..98 " "
|
R_ANGLE@118..119 ">"
|
||||||
WHERE_CLAUSE@98..131
|
SEMICOLON@119..120 ";"
|
||||||
WHERE_KW@98..103 "where"
|
WHITESPACE@120..121 "\n"
|
||||||
WHITESPACE@103..104 " "
|
|
||||||
WHERE_PRED@104..131
|
|
||||||
FOR_TYPE@104..121
|
|
||||||
FOR_KW@104..107 "for"
|
|
||||||
TYPE_PARAM_LIST@107..111
|
|
||||||
L_ANGLE@107..108 "<"
|
|
||||||
LIFETIME_PARAM@108..110
|
|
||||||
LIFETIME@108..110 "\'a"
|
|
||||||
R_ANGLE@110..111 ">"
|
|
||||||
WHITESPACE@111..112 " "
|
|
||||||
REFERENCE_TYPE@112..121
|
|
||||||
AMP@112..113 "&"
|
|
||||||
LIFETIME@113..115 "\'a"
|
|
||||||
WHITESPACE@115..116 " "
|
|
||||||
MUT_KW@116..119 "mut"
|
|
||||||
WHITESPACE@119..120 " "
|
|
||||||
PATH_TYPE@120..121
|
|
||||||
PATH@120..121
|
|
||||||
PATH_SEGMENT@120..121
|
|
||||||
NAME_REF@120..121
|
|
||||||
IDENT@120..121 "T"
|
|
||||||
COLON@121..122 ":"
|
|
||||||
WHITESPACE@122..123 " "
|
|
||||||
TYPE_BOUND_LIST@123..131
|
|
||||||
TYPE_BOUND@123..131
|
|
||||||
PATH_TYPE@123..131
|
|
||||||
PATH@123..131
|
|
||||||
PATH_SEGMENT@123..131
|
|
||||||
NAME_REF@123..131
|
|
||||||
IDENT@123..131 "Iterator"
|
|
||||||
WHITESPACE@131..132 " "
|
|
||||||
BLOCK_EXPR@132..134
|
|
||||||
L_CURLY@132..133 "{"
|
|
||||||
R_CURLY@133..134 "}"
|
|
||||||
WHITESPACE@134..135 "\n"
|
|
||||||
FN_DEF@135..199
|
|
||||||
FN_KW@135..137 "fn"
|
|
||||||
WHITESPACE@137..138 " "
|
|
||||||
NAME@138..141
|
|
||||||
IDENT@138..141 "baz"
|
|
||||||
TYPE_PARAM_LIST@141..144
|
|
||||||
L_ANGLE@141..142 "<"
|
|
||||||
TYPE_PARAM@142..143
|
|
||||||
NAME@142..143
|
|
||||||
IDENT@142..143 "T"
|
|
||||||
R_ANGLE@143..144 ">"
|
|
||||||
PARAM_LIST@144..152
|
|
||||||
L_PAREN@144..145 "("
|
|
||||||
PARAM@145..151
|
|
||||||
BIND_PAT@145..147
|
|
||||||
NAME@145..147
|
|
||||||
IDENT@145..147 "_t"
|
|
||||||
COLON@147..148 ":"
|
|
||||||
WHITESPACE@148..149 " "
|
|
||||||
REFERENCE_TYPE@149..151
|
|
||||||
AMP@149..150 "&"
|
|
||||||
PATH_TYPE@150..151
|
|
||||||
PATH@150..151
|
|
||||||
PATH_SEGMENT@150..151
|
|
||||||
NAME_REF@150..151
|
|
||||||
IDENT@150..151 "T"
|
|
||||||
R_PAREN@151..152 ")"
|
|
||||||
WHITESPACE@152..153 " "
|
|
||||||
WHERE_CLAUSE@153..196
|
|
||||||
WHERE_KW@153..158 "where"
|
|
||||||
WHITESPACE@158..159 " "
|
|
||||||
WHERE_PRED@159..196
|
|
||||||
FOR_TYPE@159..186
|
|
||||||
FOR_KW@159..162 "for"
|
|
||||||
TYPE_PARAM_LIST@162..166
|
|
||||||
L_ANGLE@162..163 "<"
|
|
||||||
LIFETIME_PARAM@163..165
|
|
||||||
LIFETIME@163..165 "\'a"
|
|
||||||
R_ANGLE@165..166 ">"
|
|
||||||
WHITESPACE@166..167 " "
|
|
||||||
PATH_TYPE@167..186
|
|
||||||
PATH@167..186
|
|
||||||
PATH@167..181
|
|
||||||
PATH_SEGMENT@167..181
|
|
||||||
L_ANGLE@167..168 "<"
|
|
||||||
REFERENCE_TYPE@168..173
|
|
||||||
AMP@168..169 "&"
|
|
||||||
LIFETIME@169..171 "\'a"
|
|
||||||
WHITESPACE@171..172 " "
|
|
||||||
PATH_TYPE@172..173
|
|
||||||
PATH@172..173
|
|
||||||
PATH_SEGMENT@172..173
|
|
||||||
NAME_REF@172..173
|
|
||||||
IDENT@172..173 "T"
|
|
||||||
WHITESPACE@173..174 " "
|
|
||||||
AS_KW@174..176 "as"
|
|
||||||
WHITESPACE@176..177 " "
|
|
||||||
PATH_TYPE@177..180
|
|
||||||
PATH@177..180
|
|
||||||
PATH_SEGMENT@177..180
|
|
||||||
NAME_REF@177..180
|
|
||||||
IDENT@177..180 "Baz"
|
|
||||||
R_ANGLE@180..181 ">"
|
|
||||||
COLON2@181..183 "::"
|
|
||||||
PATH_SEGMENT@183..186
|
|
||||||
NAME_REF@183..186
|
|
||||||
IDENT@183..186 "Foo"
|
|
||||||
COLON@186..187 ":"
|
|
||||||
WHITESPACE@187..188 " "
|
|
||||||
TYPE_BOUND_LIST@188..196
|
|
||||||
TYPE_BOUND@188..196
|
|
||||||
PATH_TYPE@188..196
|
|
||||||
PATH@188..196
|
|
||||||
PATH_SEGMENT@188..196
|
|
||||||
NAME_REF@188..196
|
|
||||||
IDENT@188..196 "Iterator"
|
|
||||||
WHITESPACE@196..197 " "
|
|
||||||
BLOCK_EXPR@197..199
|
|
||||||
L_CURLY@197..198 "{"
|
|
||||||
R_CURLY@198..199 "}"
|
|
||||||
WHITESPACE@199..200 "\n"
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
type A = for<'a> fn() -> ();
|
type A = for<'a> fn() -> ();
|
||||||
fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {}
|
type B = for<'a> unsafe extern "C" fn(&'a ()) -> ();
|
||||||
fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {}
|
type Obj = for<'a> PartialEq<&'a i32>;
|
||||||
fn baz<T>(_t: &T) where for<'a> <&'a T as Baz>::Foo: Iterator {}
|
|
||||||
|
|
392
crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast
Normal file
392
crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast
Normal file
|
@ -0,0 +1,392 @@
|
||||||
|
SOURCE_FILE@0..374
|
||||||
|
FN_DEF@0..55
|
||||||
|
FN_KW@0..2 "fn"
|
||||||
|
WHITESPACE@2..3 " "
|
||||||
|
NAME@3..12
|
||||||
|
IDENT@3..12 "for_trait"
|
||||||
|
TYPE_PARAM_LIST@12..15
|
||||||
|
L_ANGLE@12..13 "<"
|
||||||
|
TYPE_PARAM@13..14
|
||||||
|
NAME@13..14
|
||||||
|
IDENT@13..14 "F"
|
||||||
|
R_ANGLE@14..15 ">"
|
||||||
|
PARAM_LIST@15..17
|
||||||
|
L_PAREN@15..16 "("
|
||||||
|
R_PAREN@16..17 ")"
|
||||||
|
WHITESPACE@17..18 "\n"
|
||||||
|
WHERE_CLAUSE@18..51
|
||||||
|
WHERE_KW@18..23 "where"
|
||||||
|
WHITESPACE@23..28 "\n "
|
||||||
|
WHERE_PRED@28..50
|
||||||
|
FOR_KW@28..31 "for"
|
||||||
|
TYPE_PARAM_LIST@31..35
|
||||||
|
L_ANGLE@31..32 "<"
|
||||||
|
LIFETIME_PARAM@32..34
|
||||||
|
LIFETIME@32..34 "\'a"
|
||||||
|
R_ANGLE@34..35 ">"
|
||||||
|
WHITESPACE@35..36 " "
|
||||||
|
PATH_TYPE@36..37
|
||||||
|
PATH@36..37
|
||||||
|
PATH_SEGMENT@36..37
|
||||||
|
NAME_REF@36..37
|
||||||
|
IDENT@36..37 "F"
|
||||||
|
COLON@37..38 ":"
|
||||||
|
WHITESPACE@38..39 " "
|
||||||
|
TYPE_BOUND_LIST@39..50
|
||||||
|
TYPE_BOUND@39..50
|
||||||
|
PATH_TYPE@39..50
|
||||||
|
PATH@39..50
|
||||||
|
PATH_SEGMENT@39..50
|
||||||
|
NAME_REF@39..41
|
||||||
|
IDENT@39..41 "Fn"
|
||||||
|
PARAM_LIST@41..50
|
||||||
|
L_PAREN@41..42 "("
|
||||||
|
PARAM@42..49
|
||||||
|
REFERENCE_TYPE@42..49
|
||||||
|
AMP@42..43 "&"
|
||||||
|
LIFETIME@43..45 "\'a"
|
||||||
|
WHITESPACE@45..46 " "
|
||||||
|
PATH_TYPE@46..49
|
||||||
|
PATH@46..49
|
||||||
|
PATH_SEGMENT@46..49
|
||||||
|
NAME_REF@46..49
|
||||||
|
IDENT@46..49 "str"
|
||||||
|
R_PAREN@49..50 ")"
|
||||||
|
COMMA@50..51 ","
|
||||||
|
WHITESPACE@51..52 "\n"
|
||||||
|
BLOCK_EXPR@52..55
|
||||||
|
L_CURLY@52..53 "{"
|
||||||
|
WHITESPACE@53..54 "\n"
|
||||||
|
R_CURLY@54..55 "}"
|
||||||
|
WHITESPACE@55..56 "\n"
|
||||||
|
FN_DEF@56..107
|
||||||
|
FN_KW@56..58 "fn"
|
||||||
|
WHITESPACE@58..59 " "
|
||||||
|
NAME@59..66
|
||||||
|
IDENT@59..66 "for_ref"
|
||||||
|
TYPE_PARAM_LIST@66..69
|
||||||
|
L_ANGLE@66..67 "<"
|
||||||
|
TYPE_PARAM@67..68
|
||||||
|
NAME@67..68
|
||||||
|
IDENT@67..68 "F"
|
||||||
|
R_ANGLE@68..69 ">"
|
||||||
|
PARAM_LIST@69..71
|
||||||
|
L_PAREN@69..70 "("
|
||||||
|
R_PAREN@70..71 ")"
|
||||||
|
WHITESPACE@71..72 "\n"
|
||||||
|
WHERE_CLAUSE@72..103
|
||||||
|
WHERE_KW@72..77 "where"
|
||||||
|
WHITESPACE@77..82 "\n "
|
||||||
|
WHERE_PRED@82..102
|
||||||
|
FOR_KW@82..85 "for"
|
||||||
|
TYPE_PARAM_LIST@85..89
|
||||||
|
L_ANGLE@85..86 "<"
|
||||||
|
LIFETIME_PARAM@86..88
|
||||||
|
LIFETIME@86..88 "\'a"
|
||||||
|
R_ANGLE@88..89 ">"
|
||||||
|
WHITESPACE@89..90 " "
|
||||||
|
REFERENCE_TYPE@90..95
|
||||||
|
AMP@90..91 "&"
|
||||||
|
LIFETIME@91..93 "\'a"
|
||||||
|
WHITESPACE@93..94 " "
|
||||||
|
PATH_TYPE@94..95
|
||||||
|
PATH@94..95
|
||||||
|
PATH_SEGMENT@94..95
|
||||||
|
NAME_REF@94..95
|
||||||
|
IDENT@94..95 "F"
|
||||||
|
COLON@95..96 ":"
|
||||||
|
WHITESPACE@96..97 " "
|
||||||
|
TYPE_BOUND_LIST@97..102
|
||||||
|
TYPE_BOUND@97..102
|
||||||
|
PATH_TYPE@97..102
|
||||||
|
PATH@97..102
|
||||||
|
PATH_SEGMENT@97..102
|
||||||
|
NAME_REF@97..102
|
||||||
|
IDENT@97..102 "Debug"
|
||||||
|
COMMA@102..103 ","
|
||||||
|
WHITESPACE@103..104 "\n"
|
||||||
|
BLOCK_EXPR@104..107
|
||||||
|
L_CURLY@104..105 "{"
|
||||||
|
WHITESPACE@105..106 "\n"
|
||||||
|
R_CURLY@106..107 "}"
|
||||||
|
WHITESPACE@107..108 "\n"
|
||||||
|
FN_DEF@108..170
|
||||||
|
FN_KW@108..110 "fn"
|
||||||
|
WHITESPACE@110..111 " "
|
||||||
|
NAME@111..121
|
||||||
|
IDENT@111..121 "for_parens"
|
||||||
|
TYPE_PARAM_LIST@121..124
|
||||||
|
L_ANGLE@121..122 "<"
|
||||||
|
TYPE_PARAM@122..123
|
||||||
|
NAME@122..123
|
||||||
|
IDENT@122..123 "F"
|
||||||
|
R_ANGLE@123..124 ">"
|
||||||
|
PARAM_LIST@124..126
|
||||||
|
L_PAREN@124..125 "("
|
||||||
|
R_PAREN@125..126 ")"
|
||||||
|
WHITESPACE@126..127 "\n"
|
||||||
|
WHERE_CLAUSE@127..166
|
||||||
|
WHERE_KW@127..132 "where"
|
||||||
|
WHITESPACE@132..137 "\n "
|
||||||
|
WHERE_PRED@137..165
|
||||||
|
FOR_KW@137..140 "for"
|
||||||
|
TYPE_PARAM_LIST@140..144
|
||||||
|
L_ANGLE@140..141 "<"
|
||||||
|
LIFETIME_PARAM@141..143
|
||||||
|
LIFETIME@141..143 "\'a"
|
||||||
|
R_ANGLE@143..144 ">"
|
||||||
|
WHITESPACE@144..145 " "
|
||||||
|
PAREN_TYPE@145..152
|
||||||
|
L_PAREN@145..146 "("
|
||||||
|
REFERENCE_TYPE@146..151
|
||||||
|
AMP@146..147 "&"
|
||||||
|
LIFETIME@147..149 "\'a"
|
||||||
|
WHITESPACE@149..150 " "
|
||||||
|
PATH_TYPE@150..151
|
||||||
|
PATH@150..151
|
||||||
|
PATH_SEGMENT@150..151
|
||||||
|
NAME_REF@150..151
|
||||||
|
IDENT@150..151 "F"
|
||||||
|
R_PAREN@151..152 ")"
|
||||||
|
COLON@152..153 ":"
|
||||||
|
WHITESPACE@153..154 " "
|
||||||
|
TYPE_BOUND_LIST@154..165
|
||||||
|
TYPE_BOUND@154..165
|
||||||
|
PATH_TYPE@154..165
|
||||||
|
PATH@154..165
|
||||||
|
PATH_SEGMENT@154..165
|
||||||
|
NAME_REF@154..156
|
||||||
|
IDENT@154..156 "Fn"
|
||||||
|
PARAM_LIST@156..165
|
||||||
|
L_PAREN@156..157 "("
|
||||||
|
PARAM@157..164
|
||||||
|
REFERENCE_TYPE@157..164
|
||||||
|
AMP@157..158 "&"
|
||||||
|
LIFETIME@158..160 "\'a"
|
||||||
|
WHITESPACE@160..161 " "
|
||||||
|
PATH_TYPE@161..164
|
||||||
|
PATH@161..164
|
||||||
|
PATH_SEGMENT@161..164
|
||||||
|
NAME_REF@161..164
|
||||||
|
IDENT@161..164 "str"
|
||||||
|
R_PAREN@164..165 ")"
|
||||||
|
COMMA@165..166 ","
|
||||||
|
WHITESPACE@166..167 "\n"
|
||||||
|
BLOCK_EXPR@167..170
|
||||||
|
L_CURLY@167..168 "{"
|
||||||
|
WHITESPACE@168..169 "\n"
|
||||||
|
R_CURLY@169..170 "}"
|
||||||
|
WHITESPACE@170..171 "\n"
|
||||||
|
FN_DEF@171..223
|
||||||
|
FN_KW@171..173 "fn"
|
||||||
|
WHITESPACE@173..174 " "
|
||||||
|
NAME@174..183
|
||||||
|
IDENT@174..183 "for_slice"
|
||||||
|
TYPE_PARAM_LIST@183..186
|
||||||
|
L_ANGLE@183..184 "<"
|
||||||
|
TYPE_PARAM@184..185
|
||||||
|
NAME@184..185
|
||||||
|
IDENT@184..185 "F"
|
||||||
|
R_ANGLE@185..186 ">"
|
||||||
|
PARAM_LIST@186..188
|
||||||
|
L_PAREN@186..187 "("
|
||||||
|
R_PAREN@187..188 ")"
|
||||||
|
WHITESPACE@188..189 "\n"
|
||||||
|
WHERE_CLAUSE@189..219
|
||||||
|
WHERE_KW@189..194 "where"
|
||||||
|
WHITESPACE@194..199 "\n "
|
||||||
|
WHERE_PRED@199..218
|
||||||
|
FOR_KW@199..202 "for"
|
||||||
|
TYPE_PARAM_LIST@202..206
|
||||||
|
L_ANGLE@202..203 "<"
|
||||||
|
LIFETIME_PARAM@203..205
|
||||||
|
LIFETIME@203..205 "\'a"
|
||||||
|
R_ANGLE@205..206 ">"
|
||||||
|
WHITESPACE@206..207 " "
|
||||||
|
SLICE_TYPE@207..214
|
||||||
|
L_BRACK@207..208 "["
|
||||||
|
REFERENCE_TYPE@208..213
|
||||||
|
AMP@208..209 "&"
|
||||||
|
LIFETIME@209..211 "\'a"
|
||||||
|
WHITESPACE@211..212 " "
|
||||||
|
PATH_TYPE@212..213
|
||||||
|
PATH@212..213
|
||||||
|
PATH_SEGMENT@212..213
|
||||||
|
NAME_REF@212..213
|
||||||
|
IDENT@212..213 "F"
|
||||||
|
R_BRACK@213..214 "]"
|
||||||
|
COLON@214..215 ":"
|
||||||
|
WHITESPACE@215..216 " "
|
||||||
|
TYPE_BOUND_LIST@216..218
|
||||||
|
TYPE_BOUND@216..218
|
||||||
|
PATH_TYPE@216..218
|
||||||
|
PATH@216..218
|
||||||
|
PATH_SEGMENT@216..218
|
||||||
|
NAME_REF@216..218
|
||||||
|
IDENT@216..218 "Eq"
|
||||||
|
COMMA@218..219 ","
|
||||||
|
WHITESPACE@219..220 "\n"
|
||||||
|
BLOCK_EXPR@220..223
|
||||||
|
L_CURLY@220..221 "{"
|
||||||
|
WHITESPACE@221..222 "\n"
|
||||||
|
R_CURLY@222..223 "}"
|
||||||
|
WHITESPACE@223..224 "\n"
|
||||||
|
FN_DEF@224..300
|
||||||
|
FN_KW@224..226 "fn"
|
||||||
|
WHITESPACE@226..227 " "
|
||||||
|
NAME@227..236
|
||||||
|
IDENT@227..236 "for_qpath"
|
||||||
|
TYPE_PARAM_LIST@236..239
|
||||||
|
L_ANGLE@236..237 "<"
|
||||||
|
TYPE_PARAM@237..238
|
||||||
|
NAME@237..238
|
||||||
|
IDENT@237..238 "T"
|
||||||
|
R_ANGLE@238..239 ">"
|
||||||
|
PARAM_LIST@239..247
|
||||||
|
L_PAREN@239..240 "("
|
||||||
|
PARAM@240..246
|
||||||
|
BIND_PAT@240..242
|
||||||
|
NAME@240..242
|
||||||
|
IDENT@240..242 "_t"
|
||||||
|
COLON@242..243 ":"
|
||||||
|
WHITESPACE@243..244 " "
|
||||||
|
REFERENCE_TYPE@244..246
|
||||||
|
AMP@244..245 "&"
|
||||||
|
PATH_TYPE@245..246
|
||||||
|
PATH@245..246
|
||||||
|
PATH_SEGMENT@245..246
|
||||||
|
NAME_REF@245..246
|
||||||
|
IDENT@245..246 "T"
|
||||||
|
R_PAREN@246..247 ")"
|
||||||
|
WHITESPACE@247..248 "\n"
|
||||||
|
WHERE_CLAUSE@248..296
|
||||||
|
WHERE_KW@248..253 "where"
|
||||||
|
WHITESPACE@253..258 "\n "
|
||||||
|
WHERE_PRED@258..295
|
||||||
|
FOR_KW@258..261 "for"
|
||||||
|
TYPE_PARAM_LIST@261..265
|
||||||
|
L_ANGLE@261..262 "<"
|
||||||
|
LIFETIME_PARAM@262..264
|
||||||
|
LIFETIME@262..264 "\'a"
|
||||||
|
R_ANGLE@264..265 ">"
|
||||||
|
WHITESPACE@265..266 " "
|
||||||
|
PATH_TYPE@266..285
|
||||||
|
PATH@266..285
|
||||||
|
PATH@266..280
|
||||||
|
PATH_SEGMENT@266..280
|
||||||
|
L_ANGLE@266..267 "<"
|
||||||
|
REFERENCE_TYPE@267..272
|
||||||
|
AMP@267..268 "&"
|
||||||
|
LIFETIME@268..270 "\'a"
|
||||||
|
WHITESPACE@270..271 " "
|
||||||
|
PATH_TYPE@271..272
|
||||||
|
PATH@271..272
|
||||||
|
PATH_SEGMENT@271..272
|
||||||
|
NAME_REF@271..272
|
||||||
|
IDENT@271..272 "T"
|
||||||
|
WHITESPACE@272..273 " "
|
||||||
|
AS_KW@273..275 "as"
|
||||||
|
WHITESPACE@275..276 " "
|
||||||
|
PATH_TYPE@276..279
|
||||||
|
PATH@276..279
|
||||||
|
PATH_SEGMENT@276..279
|
||||||
|
NAME_REF@276..279
|
||||||
|
IDENT@276..279 "Baz"
|
||||||
|
R_ANGLE@279..280 ">"
|
||||||
|
COLON2@280..282 "::"
|
||||||
|
PATH_SEGMENT@282..285
|
||||||
|
NAME_REF@282..285
|
||||||
|
IDENT@282..285 "Foo"
|
||||||
|
COLON@285..286 ":"
|
||||||
|
WHITESPACE@286..287 " "
|
||||||
|
TYPE_BOUND_LIST@287..295
|
||||||
|
TYPE_BOUND@287..295
|
||||||
|
PATH_TYPE@287..295
|
||||||
|
PATH@287..295
|
||||||
|
PATH_SEGMENT@287..295
|
||||||
|
NAME_REF@287..295
|
||||||
|
IDENT@287..295 "Iterator"
|
||||||
|
COMMA@295..296 ","
|
||||||
|
WHITESPACE@296..297 "\n"
|
||||||
|
BLOCK_EXPR@297..300
|
||||||
|
L_CURLY@297..298 "{"
|
||||||
|
WHITESPACE@298..299 "\n"
|
||||||
|
R_CURLY@299..300 "}"
|
||||||
|
WHITESPACE@300..301 "\n"
|
||||||
|
FN_DEF@301..373
|
||||||
|
FN_KW@301..303 "fn"
|
||||||
|
WHITESPACE@303..304 " "
|
||||||
|
NAME@304..314
|
||||||
|
IDENT@304..314 "for_for_fn"
|
||||||
|
TYPE_PARAM_LIST@314..317
|
||||||
|
L_ANGLE@314..315 "<"
|
||||||
|
TYPE_PARAM@315..316
|
||||||
|
NAME@315..316
|
||||||
|
IDENT@315..316 "T"
|
||||||
|
R_ANGLE@316..317 ">"
|
||||||
|
PARAM_LIST@317..319
|
||||||
|
L_PAREN@317..318 "("
|
||||||
|
R_PAREN@318..319 ")"
|
||||||
|
WHITESPACE@319..320 "\n"
|
||||||
|
WHERE_CLAUSE@320..369
|
||||||
|
WHERE_KW@320..325 "where"
|
||||||
|
WHITESPACE@325..330 "\n "
|
||||||
|
WHERE_PRED@330..368
|
||||||
|
FOR_KW@330..333 "for"
|
||||||
|
TYPE_PARAM_LIST@333..337
|
||||||
|
L_ANGLE@333..334 "<"
|
||||||
|
LIFETIME_PARAM@334..336
|
||||||
|
LIFETIME@334..336 "\'a"
|
||||||
|
R_ANGLE@336..337 ">"
|
||||||
|
WHITESPACE@337..338 " "
|
||||||
|
FOR_TYPE@338..362
|
||||||
|
FOR_KW@338..341 "for"
|
||||||
|
TYPE_PARAM_LIST@341..345
|
||||||
|
L_ANGLE@341..342 "<"
|
||||||
|
LIFETIME_PARAM@342..344
|
||||||
|
LIFETIME@342..344 "\'b"
|
||||||
|
R_ANGLE@344..345 ">"
|
||||||
|
WHITESPACE@345..346 " "
|
||||||
|
FN_POINTER_TYPE@346..362
|
||||||
|
FN_KW@346..348 "fn"
|
||||||
|
PARAM_LIST@348..362
|
||||||
|
L_PAREN@348..349 "("
|
||||||
|
PARAM@349..354
|
||||||
|
REFERENCE_TYPE@349..354
|
||||||
|
AMP@349..350 "&"
|
||||||
|
LIFETIME@350..352 "\'a"
|
||||||
|
WHITESPACE@352..353 " "
|
||||||
|
PATH_TYPE@353..354
|
||||||
|
PATH@353..354
|
||||||
|
PATH_SEGMENT@353..354
|
||||||
|
NAME_REF@353..354
|
||||||
|
IDENT@353..354 "T"
|
||||||
|
COMMA@354..355 ","
|
||||||
|
WHITESPACE@355..356 " "
|
||||||
|
PARAM@356..361
|
||||||
|
REFERENCE_TYPE@356..361
|
||||||
|
AMP@356..357 "&"
|
||||||
|
LIFETIME@357..359 "\'b"
|
||||||
|
WHITESPACE@359..360 " "
|
||||||
|
PATH_TYPE@360..361
|
||||||
|
PATH@360..361
|
||||||
|
PATH_SEGMENT@360..361
|
||||||
|
NAME_REF@360..361
|
||||||
|
IDENT@360..361 "T"
|
||||||
|
R_PAREN@361..362 ")"
|
||||||
|
COLON@362..363 ":"
|
||||||
|
WHITESPACE@363..364 " "
|
||||||
|
TYPE_BOUND_LIST@364..368
|
||||||
|
TYPE_BOUND@364..368
|
||||||
|
PATH_TYPE@364..368
|
||||||
|
PATH@364..368
|
||||||
|
PATH_SEGMENT@364..368
|
||||||
|
NAME_REF@364..368
|
||||||
|
IDENT@364..368 "Copy"
|
||||||
|
COMMA@368..369 ","
|
||||||
|
WHITESPACE@369..370 "\n"
|
||||||
|
BLOCK_EXPR@370..373
|
||||||
|
L_CURLY@370..371 "{"
|
||||||
|
WHITESPACE@371..372 "\n"
|
||||||
|
R_CURLY@372..373 "}"
|
||||||
|
WHITESPACE@373..374 "\n"
|
30
crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rs
Normal file
30
crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
fn for_trait<F>()
|
||||||
|
where
|
||||||
|
for<'a> F: Fn(&'a str),
|
||||||
|
{
|
||||||
|
}
|
||||||
|
fn for_ref<F>()
|
||||||
|
where
|
||||||
|
for<'a> &'a F: Debug,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
fn for_parens<F>()
|
||||||
|
where
|
||||||
|
for<'a> (&'a F): Fn(&'a str),
|
||||||
|
{
|
||||||
|
}
|
||||||
|
fn for_slice<F>()
|
||||||
|
where
|
||||||
|
for<'a> [&'a F]: Eq,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
fn for_qpath<T>(_t: &T)
|
||||||
|
where
|
||||||
|
for<'a> <&'a T as Baz>::Foo: Iterator,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
fn for_for_fn<T>()
|
||||||
|
where
|
||||||
|
for<'a> for<'b> fn(&'a T, &'b T): Copy,
|
||||||
|
{
|
||||||
|
}
|
|
@ -1707,7 +1707,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
|
/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
|
||||||
struct WherePred: TypeBoundsOwner { T![lifetime], TypeRef }
|
struct WherePred: TypeBoundsOwner { T![for], TypeParamList, T![lifetime], TypeRef }
|
||||||
|
|
||||||
/// Where clause.
|
/// Where clause.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue