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.rs27
1 files changed, 17 insertions, 10 deletions
diff --git a/crates/parser/src/grammar/items/consts.rs b/crates/parser/src/grammar/items/consts.rs
index 8e255985a2..e6a8aca586 100644
--- a/crates/parser/src/grammar/items/consts.rs
+++ b/crates/parser/src/grammar/items/consts.rs
@@ -25,21 +25,28 @@ fn const_or_static(p: &mut Parser<'_>, m: Marker, is_const: bool) {
}
// 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);
+ if !is_const && p.at(T![<]) {
+ // test_err generic_static
+ // static C<i32>: u32 = 0;
+ p.error("`static` may not have generic parameters");
}
- // test_err generic_static
- // static C<i32>: u32 = 0;
+ // test generic_const
+ // const C<i32>: u32 = 0;
+ // impl Foo {
+ // const C<'a>: &'a () = &();
+ // }
+ generic_params::opt_generic_param_list(p);
if p.at(T![:]) {
types::ascription(p);
+ } else if is_const {
+ // test_err missing_const_type
+ // const C = 0;
+ p.error("missing type for `const`");
} else {
- p.error("missing type for `const` or `static`");
+ // test_err missing_static_type
+ // static C = 0;
+ p.error("missing type for `static`");
}
if p.eat(T![=]) {
expressions::expr(p);