Skip to content
New issue

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

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

Already on GitHub? # to your account

Error when formatting if let with && #5863

Closed
momvart opened this issue Jul 28, 2023 · 3 comments
Closed

Error when formatting if let with && #5863

momvart opened this issue Jul 28, 2023 · 3 comments

Comments

@momvart
Copy link

momvart commented Jul 28, 2023

If we chain multiple if let blocks into a single one with &&, rustfmt fails to format or gives

error[internal]: left behind trailing whitespace

Example:

fn main() {
    let x = Some(10);
    let y = None;

    if let Some(x) = x 
&& let Some(y) = y {
        println!("Hi");
    }
}

Version: 1.6.0-nightly (2023-07-27 500647f)

@xxchan
Copy link
Contributor

xxchan commented Jul 29, 2023

This is because unstable feature let-chains is not formatted (WIP in #5203). Note a similar but different stable feature let-else can be formatted.

You need to manually format it, and remove the trailing spaces
image

@momvart
Copy link
Author

momvart commented Jul 29, 2023

I thought it should be a WIP but couldn't remember the feature name :).

@momvart
Copy link
Author

momvart commented Jul 29, 2023

Duplicate of #5177

@momvart momvart closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants