Skip to content

Commit 0924d80

Browse files
committed
Fix the assertion crash from rustdoc document indent widths
1 parent ef8b9dc commit 0924d80

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

compiler/rustc_resolve/src/rustdoc.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,11 @@ pub fn unindent_doc_fragments(docs: &mut [DocFragment]) {
136136
// Compare against either space or tab, ignoring whether they are
137137
// mixed or not.
138138
let whitespace = line.chars().take_while(|c| *c == ' ' || *c == '\t').count();
139-
cmp::min(min_indent, whitespace)
140-
+ if fragment.kind == DocFragmentKind::SugaredDoc { 0 } else { add }
139+
cmp::min(
140+
min_indent,
141+
whitespace
142+
+ (if fragment.kind == DocFragmentKind::SugaredDoc { 0 } else { add }),
143+
)
141144
}
142145
})
143146
})
@@ -151,13 +154,13 @@ pub fn unindent_doc_fragments(docs: &mut [DocFragment]) {
151154
continue;
152155
}
153156

154-
let min_indent = if fragment.kind != DocFragmentKind::SugaredDoc && min_indent > 0 {
157+
let indent = if fragment.kind != DocFragmentKind::SugaredDoc && min_indent > 0 {
155158
min_indent - add
156159
} else {
157160
min_indent
158161
};
159162

160-
fragment.indent = min_indent;
163+
fragment.indent = indent;
161164
}
162165
}
163166

tests/rustdoc/resolve-ice-124363.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
*/
3+
pub mod A {
4+
#![doc = "{
5+
Foo { },
6+
}"]
7+
}

0 commit comments

Comments
 (0)