mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Merge #3127
3127: Support unnamed arguments in function pointers r=edwin0cheng a=hanmertens Fixes #3089 Co-authored-by: Han Mertens <hanmertens@outlook.com>
This commit is contained in:
commit
5e464d058b
3 changed files with 31 additions and 1 deletions
|
@ -114,8 +114,11 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
|
|||
// test fn_pointer_param_ident_path
|
||||
// type Foo = fn(Bar::Baz);
|
||||
// type Qux = fn(baz: Bar::Baz);
|
||||
|
||||
// test fn_pointer_unnamed_arg
|
||||
// type Foo = fn(_: bar);
|
||||
Flavor::FnPointer => {
|
||||
if p.at(IDENT) && p.nth(1) == T![:] && !p.nth_at(1, T![::]) {
|
||||
if (p.at(IDENT) || p.at(UNDERSCORE)) && p.nth(1) == T![:] && !p.nth_at(1, T![::]) {
|
||||
patterns::pattern_single(p);
|
||||
types::ascription(p);
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
type Foo = fn(_: bar);
|
|
@ -0,0 +1,26 @@
|
|||
SOURCE_FILE@[0; 23)
|
||||
TYPE_ALIAS_DEF@[0; 22)
|
||||
TYPE_KW@[0; 4) "type"
|
||||
WHITESPACE@[4; 5) " "
|
||||
NAME@[5; 8)
|
||||
IDENT@[5; 8) "Foo"
|
||||
WHITESPACE@[8; 9) " "
|
||||
EQ@[9; 10) "="
|
||||
WHITESPACE@[10; 11) " "
|
||||
FN_POINTER_TYPE@[11; 21)
|
||||
FN_KW@[11; 13) "fn"
|
||||
PARAM_LIST@[13; 21)
|
||||
L_PAREN@[13; 14) "("
|
||||
PARAM@[14; 20)
|
||||
PLACEHOLDER_PAT@[14; 15)
|
||||
UNDERSCORE@[14; 15) "_"
|
||||
COLON@[15; 16) ":"
|
||||
WHITESPACE@[16; 17) " "
|
||||
PATH_TYPE@[17; 20)
|
||||
PATH@[17; 20)
|
||||
PATH_SEGMENT@[17; 20)
|
||||
NAME_REF@[17; 20)
|
||||
IDENT@[17; 20) "bar"
|
||||
R_PAREN@[20; 21) ")"
|
||||
SEMI@[21; 22) ";"
|
||||
WHITESPACE@[22; 23) "\n"
|
Loading…
Reference in a new issue