From 8198cde13b8dc7c04190e5341bce3f6a0315e99b Mon Sep 17 00:00:00 2001 From: Erlend Tobiassen Date: Tue, 22 Jan 2019 14:32:23 +0100 Subject: Update tests after allowing where predicate to accept types --- crates/ra_syntax/src/grammar/type_params.rs | 5 +++ .../data/parser/err/0027_incomplere_where_for.txt | 17 ++++----- .../data/parser/inline/ok/0003_where_pred_for.txt | 25 +++++++------- .../tests/data/parser/ok/0038_where_pred_type.rs | 1 + .../tests/data/parser/ok/0038_where_pred_type.txt | 40 ++++++++++++++++++++++ 5 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 crates/ra_syntax/tests/data/parser/ok/0038_where_pred_type.rs create mode 100644 crates/ra_syntax/tests/data/parser/ok/0038_where_pred_type.txt diff --git a/crates/ra_syntax/src/grammar/type_params.rs b/crates/ra_syntax/src/grammar/type_params.rs index a7eacf97a..369125b39 100644 --- a/crates/ra_syntax/src/grammar/type_params.rs +++ b/crates/ra_syntax/src/grammar/type_params.rs @@ -149,6 +149,11 @@ fn where_predicate(p: &mut Parser) { p.error("expected lifetime or type"); } _ => { + // test where_pred_for + // fn test() + // where + // for<'a> F: Fn(&'a str) + // { } types::type_(p); if p.at(COLON) { diff --git a/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt index 694295a60..8a2a73b9b 100644 --- a/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt +++ b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt @@ -12,14 +12,15 @@ SOURCE_FILE@[0; 30) WHERE_KW@[13; 18) WHITESPACE@[18; 19) WHERE_PRED@[19; 26) - FOR_KW@[19; 22) - TYPE_PARAM_LIST@[22; 26) - L_ANGLE@[22; 23) - LIFETIME_PARAM@[23; 25) - LIFETIME@[23; 25) "'a" - R_ANGLE@[25; 26) - err: `expected a type` - err: `expected colon` + FOR_TYPE@[19; 26) + FOR_KW@[19; 22) + TYPE_PARAM_LIST@[22; 26) + L_ANGLE@[22; 23) + LIFETIME_PARAM@[23; 25) + LIFETIME@[23; 25) "'a" + R_ANGLE@[25; 26) + err: `expected a path` + err: `expected colon` WHITESPACE@[26; 27) BLOCK@[27; 29) L_CURLY@[27; 28) diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0003_where_pred_for.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0003_where_pred_for.txt index 921bdacf4..41420ea92 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0003_where_pred_for.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0003_where_pred_for.txt @@ -18,18 +18,19 @@ SOURCE_FILE@[0; 49) WHERE_KW@[13; 18) WHITESPACE@[18; 22) WHERE_PRED@[22; 44) - FOR_KW@[22; 25) - TYPE_PARAM_LIST@[25; 29) - L_ANGLE@[25; 26) - LIFETIME_PARAM@[26; 28) - LIFETIME@[26; 28) "'a" - R_ANGLE@[28; 29) - WHITESPACE@[29; 30) - PATH_TYPE@[30; 31) - PATH@[30; 31) - PATH_SEGMENT@[30; 31) - NAME_REF@[30; 31) - IDENT@[30; 31) "F" + FOR_TYPE@[22; 31) + FOR_KW@[22; 25) + TYPE_PARAM_LIST@[25; 29) + L_ANGLE@[25; 26) + LIFETIME_PARAM@[26; 28) + LIFETIME@[26; 28) "'a" + R_ANGLE@[28; 29) + WHITESPACE@[29; 30) + PATH_TYPE@[30; 31) + PATH@[30; 31) + PATH_SEGMENT@[30; 31) + NAME_REF@[30; 31) + IDENT@[30; 31) "F" COLON@[31; 32) WHITESPACE@[32; 33) PATH_TYPE@[33; 44) diff --git a/crates/ra_syntax/tests/data/parser/ok/0038_where_pred_type.rs b/crates/ra_syntax/tests/data/parser/ok/0038_where_pred_type.rs new file mode 100644 index 000000000..8bfc341a5 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0038_where_pred_type.rs @@ -0,0 +1 @@ +fn test() where (u64, u64): Foo {} \ No newline at end of file diff --git a/crates/ra_syntax/tests/data/parser/ok/0038_where_pred_type.txt b/crates/ra_syntax/tests/data/parser/ok/0038_where_pred_type.txt new file mode 100644 index 000000000..4842e9b90 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0038_where_pred_type.txt @@ -0,0 +1,40 @@ +SOURCE_FILE@[0; 34) + FN_DEF@[0; 34) + FN_KW@[0; 2) + WHITESPACE@[2; 3) + NAME@[3; 7) + IDENT@[3; 7) "test" + PARAM_LIST@[7; 9) + L_PAREN@[7; 8) + R_PAREN@[8; 9) + WHITESPACE@[9; 10) + WHERE_CLAUSE@[10; 31) + WHERE_KW@[10; 15) + WHITESPACE@[15; 16) + WHERE_PRED@[16; 31) + TUPLE_TYPE@[16; 26) + L_PAREN@[16; 17) + PATH_TYPE@[17; 20) + PATH@[17; 20) + PATH_SEGMENT@[17; 20) + NAME_REF@[17; 20) + IDENT@[17; 20) "u64" + COMMA@[20; 21) + WHITESPACE@[21; 22) + PATH_TYPE@[22; 25) + PATH@[22; 25) + PATH_SEGMENT@[22; 25) + NAME_REF@[22; 25) + IDENT@[22; 25) "u64" + R_PAREN@[25; 26) + COLON@[26; 27) + WHITESPACE@[27; 28) + PATH_TYPE@[28; 31) + PATH@[28; 31) + PATH_SEGMENT@[28; 31) + NAME_REF@[28; 31) + IDENT@[28; 31) "Foo" + WHITESPACE@[31; 32) + BLOCK@[32; 34) + L_CURLY@[32; 33) + R_CURLY@[33; 34) -- cgit v1.2.3