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