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

'error[internal]: left behind trailing whitespace' after closure argument list #6423

Open
Tastaturtaste opened this issue Dec 22, 2024 · 0 comments

Comments

@Tastaturtaste
Copy link

As the title says, the following code leads to an internal error:

fn main() {
    Some(1).map(|id| 
    // Some comment explaining what I am doing
    id + id);
}

Link to playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=0714c35f8e91a1bb365a8059fa532329
The exact error message:

error[internal]: left behind trailing whitespace
--> /playground/src/main.rs:2:2:21
   |
2 | Some(1).map(|id|
   |                          ^
   |

rustfmt version: 1.8.0-stable

Alternative: This also happens with a linebreak before the second id in the addition
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b12719274b196887bbd5691c063a173f

On a cursory skim the only duplicate I found was #2896, which is closed and locked without any resolution. Honestly I am a bit taken aback by the fact this bug from 2018 still seems to be around. I also noticed there are quite a few issues for this error caused by a wide variety of (valid) code patterns. Is there any path forward to fixing these? Is there guidance available if I wanted to try and fix this? Maybe it is already known what would have to be changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant