Unnamed repository; edit this file 'description' to name the repository.
fix: report `expected type, found {` in parser
Amit Singhmar 7 weeks ago
parent f4b77dc · commit 77f0ee3
-rw-r--r--crates/parser/src/grammar/types.rs3
-rw-r--r--crates/parser/test_data/parser/err/0025_nope.rast2
-rw-r--r--crates/parser/test_data/parser/err/0027_incomplete_where_for.rast2
3 files changed, 5 insertions, 2 deletions
diff --git a/crates/parser/src/grammar/types.rs b/crates/parser/src/grammar/types.rs
index c62356d5c9..667bb68c64 100644
--- a/crates/parser/src/grammar/types.rs
+++ b/crates/parser/src/grammar/types.rs
@@ -59,6 +59,9 @@ fn type_with_bounds_cond(p: &mut Parser<'_>, allow_bounds: bool) {
}
_ if paths::is_path_start(p) => path_or_macro_type(p, allow_bounds),
LIFETIME_IDENT if p.nth_at(1, T![+]) => bare_dyn_trait_type(p),
+ T!['{'] => {
+ p.err_recover("expected type, found `{`", TYPE_RECOVERY_SET);
+ }
_ => {
p.err_recover("expected type", TYPE_RECOVERY_SET);
}
diff --git a/crates/parser/test_data/parser/err/0025_nope.rast b/crates/parser/test_data/parser/err/0025_nope.rast
index b6bc008837..23964ab9d9 100644
--- a/crates/parser/test_data/parser/err/0025_nope.rast
+++ b/crates/parser/test_data/parser/err/0025_nope.rast
@@ -194,7 +194,7 @@ SOURCE_FILE
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"
-error 95: expected type
+error 95: expected type, found `{`
error 95: expected COMMA
error 96: expected field
error 98: expected field declaration
diff --git a/crates/parser/test_data/parser/err/0027_incomplete_where_for.rast b/crates/parser/test_data/parser/err/0027_incomplete_where_for.rast
index 3768a55d53..31db794d9f 100644
--- a/crates/parser/test_data/parser/err/0027_incomplete_where_for.rast
+++ b/crates/parser/test_data/parser/err/0027_incomplete_where_for.rast
@@ -26,5 +26,5 @@ SOURCE_FILE
L_CURLY "{"
R_CURLY "}"
WHITESPACE "\n"
-error 26: expected type
+error 26: expected type, found `{`
error 26: expected colon