mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-27 10:17:15 +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.
|
||||
if is_const {
|
||||
// test generic_const
|
||||
// const C<i32>: u32 = 0;
|
||||
// impl Foo {
|
||||
// const C<'a>: &'a () = &();
|
||||
// }
|
||||
generic_params::opt_generic_param_list(p);
|
||||
} else if p.at(T![<]) {
|
||||
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);
|
||||
|
|
@ -44,7 +43,7 @@ fn const_or_static(p: &mut Parser<'_>, m: Marker, is_const: bool) {
|
|||
// test_err missing_const_type
|
||||
// const C = 0;
|
||||
p.error("missing type for `const`");
|
||||
} else if !p.at(T![<]) {
|
||||
} else {
|
||||
// test_err missing_static_type
|
||||
// static C = 0;
|
||||
p.error("missing type for `static`");
|
||||
|
|
|
|||
|
|
@ -4,39 +4,24 @@ SOURCE_FILE
|
|||
WHITESPACE " "
|
||||
NAME
|
||||
IDENT "C"
|
||||
ERROR
|
||||
L_ANGLE "<"
|
||||
ERROR
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
GENERIC_PARAM_LIST
|
||||
L_ANGLE "<"
|
||||
TYPE_PARAM
|
||||
NAME
|
||||
IDENT "i32"
|
||||
ERROR
|
||||
R_ANGLE ">"
|
||||
ERROR
|
||||
R_ANGLE ">"
|
||||
COLON ":"
|
||||
WHITESPACE " "
|
||||
ERROR
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "u32"
|
||||
WHITESPACE " "
|
||||
ERROR
|
||||
WHITESPACE " "
|
||||
PATH_TYPE
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "u32"
|
||||
WHITESPACE " "
|
||||
EQ "="
|
||||
WHITESPACE " "
|
||||
ERROR
|
||||
INT_NUMBER "0"
|
||||
ERROR
|
||||
WHITESPACE " "
|
||||
LITERAL
|
||||
INT_NUMBER "0"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n"
|
||||
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