Skip to content

Commit 4fbfc7e

Browse files
Fix #6069
1 parent ead0fc9 commit 4fbfc7e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/items.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,9 @@ pub(crate) fn format_trait(
11661166

11671167
// FIXME(#2055): rustfmt fails to format when there are comments between trait bounds.
11681168
if !bounds.is_empty() {
1169-
let ident_hi = context
1170-
.snippet_provider
1171-
.span_after(item.span, item.ident.as_str());
1169+
// Retrieve *unnormalized* ident (See #6069)
1170+
let source_ident = context.snippet(item.ident.span);
1171+
let ident_hi = context.snippet_provider.span_after(item.span, source_ident);
11721172
let bound_hi = bounds.last().unwrap().span().hi();
11731173
let snippet = context.snippet(mk_sp(ident_hi, bound_hi));
11741174
if contains_comment(snippet) {

tests/rustfmt/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn rustfmt_emits_error_on_line_overflow_true() {
176176
#[test]
177177
#[allow(non_snake_case)]
178178
fn dont_emit_ICE() {
179-
let files = ["tests/target/issue_5728.rs", "tests/target/issue_5729.rs"];
179+
let files = ["tests/target/issue_5728.rs", "tests/target/issue_5729.rs", "tests/target/issue_6069.rs"];
180180

181181
for file in files {
182182
let args = [file];

tests/target/issue_6069.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// `Foó` as written here ends with ASCII 6F `'o'` followed by `'\u{0301}'` COMBINING ACUTE ACCENT.
2+
// The compiler normalizes that combination to NFC form, `'\u{00F3}'` LATIN SMALL LETTER O WITH ACUTE.
3+
trait Foó: Bar {}

0 commit comments

Comments
 (0)