-
Notifications
You must be signed in to change notification settings - Fork 898
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
ICE when formatting trait declaration with non-NFC name #6069
Comments
@Jules-Bertholet you mentioned back in #6058 that the compiler is now normalizing idents? Has that been a thing for a while now? Is there a way to get the unnormalized ident? The only way I can think to do so is to use the ident's span. Let me know if I'm understanding this one correctly. I believe what you mentioned above is that This is where the panic happens: Lines 1169 to 1171 in 8486837
|
@ytmimi You are.
Identifier normalization has been a thing since Rust started supporting non-ASCII idents, changing normalization behavior would have been a breaking change (it would change whether two identifiers are considered to refer to the same thing). I can't speak to the history of rustc's exact implementation though |
Cool! This should be a straightforward fix. As mentioned, this is where the panic originates: Lines 1169 to 1171 in 8486837
And I think the fix here is to ensure we're using the right needle when searching for the end of the ident: + // Idents are NFC normalized by the compiler. To make sure we provide the right needle to
+ // `span_after` we grab the ident from the source file. See #6069
+ let source_ident = context.snippet(item.ident.span);
let ident_hi = context
.snippet_provider
- .span_after(item.span, item.ident.as_str());
+ .span_after(item.span, source_ident); Then we should add a test case with the snippet posted above to a file like Lines 176 to 186 in 8486837
|
Also fixes rust-lang#6069.
Also fixes rust-lang#6069.
The
ó
above is two codepoints, ASCIIo
followed by U+0301 COMBINING ACUTE ACCENT. It NFC-normalizes toó
, U+00F3 LATIN SMALL LETTER O WITH ACUTE.Trying to format the above results in:
The text was updated successfully, but these errors were encountered: