Skip to content

Commit 5e464d0

Browse files
Merge #3127
3127: Support unnamed arguments in function pointers r=edwin0cheng a=hanmertens Fixes #3089 Co-authored-by: Han Mertens <[email protected]>
2 parents 3da53ab + bed9c08 commit 5e464d0

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

crates/ra_parser/src/grammar/params.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
114114
// test fn_pointer_param_ident_path
115115
// type Foo = fn(Bar::Baz);
116116
// type Qux = fn(baz: Bar::Baz);
117+
118+
// test fn_pointer_unnamed_arg
119+
// type Foo = fn(_: bar);
117120
Flavor::FnPointer => {
118-
if p.at(IDENT) && p.nth(1) == T![:] && !p.nth_at(1, T![::]) {
121+
if (p.at(IDENT) || p.at(UNDERSCORE)) && p.nth(1) == T![:] && !p.nth_at(1, T![::]) {
119122
patterns::pattern_single(p);
120123
types::ascription(p);
121124
} else {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Foo = fn(_: bar);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
SOURCE_FILE@[0; 23)
2+
TYPE_ALIAS_DEF@[0; 22)
3+
TYPE_KW@[0; 4) "type"
4+
WHITESPACE@[4; 5) " "
5+
NAME@[5; 8)
6+
IDENT@[5; 8) "Foo"
7+
WHITESPACE@[8; 9) " "
8+
EQ@[9; 10) "="
9+
WHITESPACE@[10; 11) " "
10+
FN_POINTER_TYPE@[11; 21)
11+
FN_KW@[11; 13) "fn"
12+
PARAM_LIST@[13; 21)
13+
L_PAREN@[13; 14) "("
14+
PARAM@[14; 20)
15+
PLACEHOLDER_PAT@[14; 15)
16+
UNDERSCORE@[14; 15) "_"
17+
COLON@[15; 16) ":"
18+
WHITESPACE@[16; 17) " "
19+
PATH_TYPE@[17; 20)
20+
PATH@[17; 20)
21+
PATH_SEGMENT@[17; 20)
22+
NAME_REF@[17; 20)
23+
IDENT@[17; 20) "bar"
24+
R_PAREN@[20; 21) ")"
25+
SEMI@[21; 22) ";"
26+
WHITESPACE@[22; 23) "\n"

0 commit comments

Comments
 (0)