Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ItsEthra opened this issue Dec 10, 2022 · 1 comment · Fixed by #13762
Closed

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

ItsEthra opened this issue Dec 10, 2022 · 1 comment · Fixed by #13762
Assignees
Labels
A-parser parser issues C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now

Comments

@ItsEthra
Copy link

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)

@lnicola lnicola added S-actionable Someone could pick this issue up and work on it right now A-parser parser issues C-bug Category: bug labels Dec 10, 2022
@lnicola
Copy link
Member

lnicola commented Dec 10, 2022

Minimized:

|| _ = 42;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser parser issues C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants