mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-26 17:57:19 +00:00
Allow generic_param_list for static items
This commit is contained in:
parent
216db6d5b4
commit
2707cf7ce6
2 changed files with 25 additions and 41 deletions
|
|
@ -25,18 +25,17 @@ fn const_or_static(p: &mut Parser<'_>, m: Marker, is_const: bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Recover on statics with generic params/where clause.
|
// FIXME: Recover on statics with generic params/where clause.
|
||||||
if is_const {
|
if !is_const && p.at(T![<]) {
|
||||||
// test generic_const
|
// test_err generic_static
|
||||||
// const C<i32>: u32 = 0;
|
// static C<i32>: u32 = 0;
|
||||||
// impl Foo {
|
|
||||||
// const C<'a>: &'a () = &();
|
|
||||||
// }
|
|
||||||
generic_params::opt_generic_param_list(p);
|
|
||||||
} else if p.at(T![<]) {
|
|
||||||
p.error("`static` may not have generic parameters");
|
p.error("`static` may not have generic parameters");
|
||||||
}
|
}
|
||||||
// test_err generic_static
|
// test generic_const
|
||||||
// static C<i32>: u32 = 0;
|
// const C<i32>: u32 = 0;
|
||||||
|
// impl Foo {
|
||||||
|
// const C<'a>: &'a () = &();
|
||||||
|
// }
|
||||||
|
generic_params::opt_generic_param_list(p);
|
||||||
|
|
||||||
if p.at(T![:]) {
|
if p.at(T![:]) {
|
||||||
types::ascription(p);
|
types::ascription(p);
|
||||||
|
|
@ -44,7 +43,7 @@ fn const_or_static(p: &mut Parser<'_>, m: Marker, is_const: bool) {
|
||||||
// test_err missing_const_type
|
// test_err missing_const_type
|
||||||
// const C = 0;
|
// const C = 0;
|
||||||
p.error("missing type for `const`");
|
p.error("missing type for `const`");
|
||||||
} else if !p.at(T![<]) {
|
} else {
|
||||||
// test_err missing_static_type
|
// test_err missing_static_type
|
||||||
// static C = 0;
|
// static C = 0;
|
||||||
p.error("missing type for `static`");
|
p.error("missing type for `static`");
|
||||||
|
|
|
||||||
|
|
@ -4,39 +4,24 @@ SOURCE_FILE
|
||||||
WHITESPACE " "
|
WHITESPACE " "
|
||||||
NAME
|
NAME
|
||||||
IDENT "C"
|
IDENT "C"
|
||||||
ERROR
|
GENERIC_PARAM_LIST
|
||||||
L_ANGLE "<"
|
L_ANGLE "<"
|
||||||
ERROR
|
TYPE_PARAM
|
||||||
PATH
|
NAME
|
||||||
PATH_SEGMENT
|
|
||||||
NAME_REF
|
|
||||||
IDENT "i32"
|
IDENT "i32"
|
||||||
ERROR
|
R_ANGLE ">"
|
||||||
R_ANGLE ">"
|
|
||||||
ERROR
|
|
||||||
COLON ":"
|
COLON ":"
|
||||||
WHITESPACE " "
|
WHITESPACE " "
|
||||||
ERROR
|
PATH_TYPE
|
||||||
PATH
|
PATH
|
||||||
PATH_SEGMENT
|
PATH_SEGMENT
|
||||||
NAME_REF
|
NAME_REF
|
||||||
IDENT "u32"
|
IDENT "u32"
|
||||||
WHITESPACE " "
|
WHITESPACE " "
|
||||||
ERROR
|
|
||||||
EQ "="
|
EQ "="
|
||||||
WHITESPACE " "
|
WHITESPACE " "
|
||||||
ERROR
|
LITERAL
|
||||||
INT_NUMBER "0"
|
INT_NUMBER "0"
|
||||||
ERROR
|
|
||||||
SEMICOLON ";"
|
SEMICOLON ";"
|
||||||
WHITESPACE "\n"
|
WHITESPACE "\n"
|
||||||
error 8: `static` may not have generic parameters
|
error 8: `static` may not have generic parameters
|
||||||
error 8: expected SEMICOLON
|
|
||||||
error 8: expected an item
|
|
||||||
error 12: expected an item
|
|
||||||
error 12: expected an item
|
|
||||||
error 13: expected an item
|
|
||||||
error 18: expected an item
|
|
||||||
error 19: expected an item
|
|
||||||
error 21: expected an item
|
|
||||||
error 22: expected an item
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue