rust-lang / rust-lang/rust

E0593 could suggest using tuple as closure arg

Open
#123,870 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics A-suggestion-diagnostics T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
` stderr.lines().enumerate().find(|i, line| line == ice_msg)`
Current output
Checking icemaker v0.1.0 (/home/matthias/vcs/github/icemaker_tree_update/icemaker)
error[E0593]: closure is expected to take 1 argument, but it takes 2 arguments
    --> src/main.rs:1082:44
     |
1082 |                 stderr.lines().enumerate().find(|i, line| line == ice_msg)
     |                                            ^^^^ --------- takes 2 arguments
     |                                            |
     |                                            expected closure that takes 1 argument

For more information about this error, try `rustc --explain E0593`.
Desired output
something like help/hint:
wrap the closure args in a tuple

1082 |                 stderr.lines().enumerate().find(|(i, line)| line == ice_msg)
     | +                                               -+-------+- warp closure args in a tuple
Rationale and extra context

No response

Other cases

No response

Rust Version
rustc 1.79.0-nightly (a07f3eb43 2024-04-11)
binary: rustc
commit-hash: a07f3eb43acc5df851e15176c7081a900a30a4d7
commit-date: 2024-04-11
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing E0593 with the closure example in the issue and inspect the compiler's diagnostic handling for this error. The work is done when a suitable tuple-argument hint is emitted for this case without misleading diagnostics; the issue does not name a source file or test to update.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.