From ec131b6c7bd27d9034ed5e600b80420d35c00a21 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 6 Nov 2018 21:19:32 +0300 Subject: grammar: fix where clause parsing closes #205 --- crates/ra_syntax/src/grammar/type_params.rs | 6 ++++- .../data/parser/err/0027_incomplere_where_for.rs | 3 +++ .../data/parser/err/0027_incomplere_where_for.txt | 27 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.rs create mode 100644 crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt (limited to 'crates') diff --git a/crates/ra_syntax/src/grammar/type_params.rs b/crates/ra_syntax/src/grammar/type_params.rs index 68eca0ce8..f4c98675c 100644 --- a/crates/ra_syntax/src/grammar/type_params.rs +++ b/crates/ra_syntax/src/grammar/type_params.rs @@ -135,7 +135,11 @@ fn where_predicate(p: &mut Parser) { if p.at(FOR_KW) { types::for_binder(p); } - types::path_type(p); + if paths::is_path_start(p) || p.at(L_ANGLE) { + types::path_type_(p, false); + } else { + p.error("expected a type"); + } if p.at(COLON) { bounds(p); } else { diff --git a/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.rs b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.rs new file mode 100644 index 000000000..2792c2084 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.rs @@ -0,0 +1,3 @@ +fn foo() + where for<'a> +{} 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 new file mode 100644 index 000000000..94b75a656 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt @@ -0,0 +1,27 @@ +ROOT@[0; 30) + FN_DEF@[0; 29) + FN_KW@[0; 2) + WHITESPACE@[2; 3) + NAME@[3; 6) + IDENT@[3; 6) "foo" + PARAM_LIST@[6; 8) + L_PAREN@[6; 7) + R_PAREN@[7; 8) + WHITESPACE@[8; 13) + WHERE_CLAUSE@[13; 26) + 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` + WHITESPACE@[26; 27) + BLOCK@[27; 29) + L_CURLY@[27; 28) + R_CURLY@[28; 29) + WHITESPACE@[29; 30) -- cgit v1.2.3