Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/parser/src/grammar/items/consts.rs')
| -rw-r--r-- | crates/parser/src/grammar/items/consts.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/parser/src/grammar/items/consts.rs b/crates/parser/src/grammar/items/consts.rs index 9549ec9b40..8e255985a2 100644 --- a/crates/parser/src/grammar/items/consts.rs +++ b/crates/parser/src/grammar/items/consts.rs @@ -24,6 +24,18 @@ fn const_or_static(p: &mut Parser<'_>, m: Marker, is_const: bool) { name(p); } + // FIXME: Recover on statics with generic params/where clause. + if is_const { + // test generic_const + // const C<i32>: u32 = 0; + // impl Foo { + // const C<'a>: &'a () = &(); + // } + generic_params::opt_generic_param_list(p); + } + // test_err generic_static + // static C<i32>: u32 = 0; + if p.at(T![:]) { types::ascription(p); } else { @@ -32,6 +44,20 @@ fn const_or_static(p: &mut Parser<'_>, m: Marker, is_const: bool) { if p.eat(T![=]) { expressions::expr(p); } + + if is_const { + // test const_where_clause + // const C<i32>: u32 = 0 + // where i32: Copy; + // trait Foo { + // const C: i32 where i32: Copy; + // } + generic_params::opt_where_clause(p); + } + // test_err static_where_clause + // static C: u32 = 0 + // where i32: Copy; + p.expect(T![;]); m.complete(p, if is_const { CONST } else { STATIC }); } |