Skip to content

Discarding value in closure with underscore shows up as syntax error #13757

Closed
@ItsEthra

Description

@ItsEthra

In this code:

fn foo(_: impl FnOnce() -> ()) {}

fn main() {
    let bar = || { 5 };
    foo(|| _ = bar());
}

When calling foo, rust-analyzer suggests that there is a syntax error although code compiles fine.

Syntax Error: expected expression rust-analyzer[syntax-error]
Syntax Error: expected COMMA rust-analyzer[syntax-error]
Syntax Error: expected SEMICOLON rust-analyzer[syntax-error]

image

rust-analyzer version: rust-analyzer version: 0.3.1309-standalone (a2beeb8 2022-12-04)
rustc version: rustc 1.67.0-nightly (c97b539e4 2022-11-30)

Metadata

Metadata

Labels

A-parserparser issuesC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions