From 0e10e77a7820d08332744d91e44940a2321138c3 Mon Sep 17 00:00:00 2001 From: Han Mertens Date: Wed, 12 Feb 2020 21:40:05 +0100 Subject: Support unnamed arguments in function pointers Fixes #3089 --- crates/ra_parser/src/grammar/params.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_parser') diff --git a/crates/ra_parser/src/grammar/params.rs b/crates/ra_parser/src/grammar/params.rs index ed4f93347..4abd61be7 100644 --- a/crates/ra_parser/src/grammar/params.rs +++ b/crates/ra_parser/src/grammar/params.rs @@ -115,7 +115,7 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) { // type Foo = fn(Bar::Baz); // type Qux = fn(baz: Bar::Baz); 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 { -- cgit v1.2.3 From b435fe8b771c00d5df1f781b21ddae55d64ded42 Mon Sep 17 00:00:00 2001 From: Han Mertens Date: Wed, 12 Feb 2020 22:55:37 +0100 Subject: Add test for unnamed argument in function pointer --- crates/ra_parser/src/grammar/params.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'crates/ra_parser') diff --git a/crates/ra_parser/src/grammar/params.rs b/crates/ra_parser/src/grammar/params.rs index 4abd61be7..272661b1d 100644 --- a/crates/ra_parser/src/grammar/params.rs +++ b/crates/ra_parser/src/grammar/params.rs @@ -114,6 +114,9 @@ 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.at(UNDERSCORE)) && p.nth(1) == T![:] && !p.nth_at(1, T![::]) { patterns::pattern_single(p); -- cgit v1.2.3