Skip to content

Commit 1befb0b

Browse files
committed
fix: Only add extra padding to the first group's last file
1 parent 7c2c3c0 commit 1befb0b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ impl AnnotateSnippetEmitter {
213213
file_ann.swap(0, pos);
214214
}
215215

216+
let file_ann_len = file_ann.len();
216217
for (file_idx, (file, annotations)) in file_ann.into_iter().enumerate() {
217218
if should_show_source_code(&self.ignored_directories_in_source_blocks, sm, &file) {
218219
if let Some(snippet) = self.annotated_snippet(annotations, &file.name, sm) {
@@ -240,6 +241,7 @@ impl AnnotateSnippetEmitter {
240241
// ╰ warning: this was previously accepted
241242
if let Some(c) = children.first()
242243
&& (!c.span.has_primary_spans() && !c.span.has_span_labels())
244+
&& file_idx == file_ann_len - 1
243245
{
244246
group = group.element(Padding);
245247
}

tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ LL | println!();
1919
error: macro expansion ignores `{` and any tokens following
2020
--> $SRC_DIR/std/src/macros.rs:LL:COL
2121
|
22-
|
2322
::: $DIR/main-alongside-macro-calls.rs:30:1
2423
|
2524
LL | println!();
@@ -42,7 +41,6 @@ LL | println!();
4241
error: macro expansion ignores `{` and any tokens following
4342
--> $SRC_DIR/std/src/macros.rs:LL:COL
4443
|
45-
|
4644
::: $DIR/main-alongside-macro-calls.rs:34:1
4745
|
4846
LL | println!();

0 commit comments

Comments
 (0)