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

Compiler error for if/let chaining when not using it inside a map closure syntax error #116608

Closed
tlockhart1996 opened this issue Oct 10, 2023 · 1 comment · Fixed by #116645
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tlockhart1996
Copy link

Code

fn main() {
    vec![].into_iter().map({ |x| 
        let y = x;
        y
    })
}

Current output

error[E0658]: `let` expressions in this position are unstable

Desired output

Something related to 
`map({ |x|` is a syntax error and should be `map(|x| {`

Rationale and extra context

N/A

Other cases

No response

Anything else?

No response

@tlockhart1996 tlockhart1996 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 10, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 10, 2023
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 11, 2023
estebank added a commit to estebank/rust that referenced this issue Oct 11, 2023
When parsing a closure without a body that is surrounded by a block,
suggest moving the opening brace after the closure head.

Fix rust-lang#116608.
@estebank
Copy link
Contributor

After #116645:

error: expected expression, found `let` statement
  --> $DIR/ruby_style_closure_parse_error.rs:4:9
   |
LL |     let _ = vec![1, 2, 3].into_iter().map({|x| 
   |                                            --- while parsing the body of this closure
LL |         let y = x;
   |         ^^^
   |
   = note: only supported directly in conditions of `if` and `while` expressions
help: you might have meant to open the body of the closure, instead of enclosing the closure in a block
   |
LL -     let _ = vec![1, 2, 3].into_iter().map({|x| 
LL +     let _ = vec![1, 2, 3].into_iter().map(|x| { 

bors added a commit to rust-lang-ci/rust that referenced this issue Oct 13, 2023
Detect ruby-style closure in parser

When parsing a closure without a body that is surrounded by a block, suggest moving the opening brace after the closure head.

Fix rust-lang#116608.
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 13, 2023
Detect ruby-style closure in parser

When parsing a closure without a body that is surrounded by a block, suggest moving the opening brace after the closure head.

Fix rust-lang#116608.
@bors bors closed this as completed in 6b2c6c7 Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants