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 #5599

Closed
LittleGuest opened this issue Nov 11, 2022 · 1 comment
Closed

error[internal]: left behind trailing whitespace #5599

LittleGuest opened this issue Nov 11, 2022 · 1 comment

Comments

@LittleGuest
Copy link

Hi, I'm having a problem with cargo fmt , like this:

error[internal]: left behind trailing whitespace
 --> /playground/src/main.rs:5:5:1
  |
5 |         
  | ^^^^^^^^
  |

warning: rustfmt has failed to format. See previous 1 errors.

code looks like this:

fn main() {
    let a = Some(1);
    let Some(a) = a else{
        panic!("none");
        
    };
    println!("{a}");
}

rustc 1.65.0
rustfmt 1.5.1-stable (897e3755 2022-11-02)

@ytmimi
Copy link
Contributor

ytmimi commented Nov 11, 2022

Thanks for reaching out. rustfmt doesn't handle let-else formatting because the rules for how it should be formatted are still being discussed in rust-lang/style-team#165

Because rustfmt doesn't format let-else statements the code is left as is by rustfmt, which means the trailing whitespace that exists in the original snippet is also left alone, triggering the internal error that you're seeing. In this case the internal error is rustfmts way of letting you know that there's trailing whitespace in the text of your program that requires manual intervention to remove.

You might also want to follow #4914 to keep track of the implementation on the rustfmt side once the rules have been codified in the fmt-rfc linked above.

@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Nov 11, 2022
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

2 participants