Skip to content

panic: left behind trailing whitespace #6549

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

Open
35VLG84 opened this issue Apr 25, 2025 · 1 comment
Open

panic: left behind trailing whitespace #6549

35VLG84 opened this issue Apr 25, 2025 · 1 comment

Comments

@35VLG84
Copy link

35VLG84 commented Apr 25, 2025

Hello rustfmt team,

Following code will cause panic with stable (1.86.0) and nightly (as 2025-04-25) rustc / rustfmt.

The MRE is also available here: https://github.com/35VLG84/rustfmt-ice as there is a space character which is triggering the ICE.

Here is the stacktrace: rustc-ice-2025-04-25T14_25_14-537623.txt It's also available in the above repository.

MRE

There is a space at the end of the second line (after '¶').
If you remove that space, then the ICE goes away.
Same is true if the comment or the last test line is removed.

fn main() {
    let m = matches!(
        c,
        | 'a' | '¶'
        | 'b' // abc
        | '¿'
    );
}
od -c src/main.rs

0000000   f   n       m   a   i   n   (   )       {  \n
0000020   l   e   t       m       =       m   a   t   c   h   e   s   !
0000040   (  \n                                   c   ,  \n
0000060                       |       '   a   '       |       ' 302 266
0000100   '      \n                                   |       '   b   '
0000120       /   /       a   b   c  \n
0000140   |       ' 302 277   '  \n                   )   ;  \n   }  \n
0000160

Thank you for working with rustfmt, it's really nice and helpful tool!

@35VLG84
Copy link
Author

35VLG84 commented Apr 25, 2025

Also if the '¶' is changed to ascii char, the ICE goes away. But even then rustfmt fails to format the code.

error[internal]: left behind trailing whitespace
....
warning: rustfmt has failed to format. See previous 1 errors.

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