Skip to content

Commit bc770a1

Browse files
Merge pull request #21951 from Amit5601/fix-parser-return-type
fix: report `expected type, found {` in parser
2 parents 13ed509 + 77f0ee3 commit bc770a1

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

crates/parser/src/grammar/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ fn type_with_bounds_cond(p: &mut Parser<'_>, allow_bounds: bool) {
5959
}
6060
_ if paths::is_path_start(p) => path_or_macro_type(p, allow_bounds),
6161
LIFETIME_IDENT if p.nth_at(1, T![+]) => bare_dyn_trait_type(p),
62+
T!['{'] => {
63+
p.err_recover("expected type, found `{`", TYPE_RECOVERY_SET);
64+
}
6265
_ => {
6366
p.err_recover("expected type", TYPE_RECOVERY_SET);
6467
}

crates/parser/test_data/parser/err/0025_nope.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ SOURCE_FILE
194194
WHITESPACE "\n"
195195
R_CURLY "}"
196196
WHITESPACE "\n"
197-
error 95: expected type
197+
error 95: expected type, found `{`
198198
error 95: expected COMMA
199199
error 96: expected field
200200
error 98: expected field declaration

crates/parser/test_data/parser/err/0027_incomplete_where_for.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ SOURCE_FILE
2626
L_CURLY "{"
2727
R_CURLY "}"
2828
WHITESPACE "\n"
29-
error 26: expected type
29+
error 26: expected type, found `{`
3030
error 26: expected colon

0 commit comments

Comments
 (0)