diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-12 12:26:16 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-13 09:53:36 +0000 |
| commit | 2e2a4797a26b0effe15815b403be4ba752cc7a0b (patch) | |
| tree | 35c22373d4cf4554c3bf45f178be06598c929666 /compiler/rustc_errors | |
| parent | 063b1675b2ed27948a7821af639a28c1a669d868 (diff) | |
| download | rust-2e2a4797a26b0effe15815b403be4ba752cc7a0b.tar.gz rust-2e2a4797a26b0effe15815b403be4ba752cc7a0b.zip | |
Don't emit empty notes
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index aaf0699f0dc..268f17f86fe 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1431,25 +1431,27 @@ impl EmitterWriter { }; for (i, annotation) in annotations.into_iter().enumerate() { if let Some(label) = &annotation.label { - let style = if annotation.is_primary { - Style::LabelPrimary - } else { - Style::LabelSecondary - }; - if annotation_id == 0 { - buffer.prepend(line_idx, " |", Style::LineNumber); - for _ in 0..max_line_num_len { - buffer.prepend(line_idx, " ", Style::NoStyle); + if !label.is_empty() { + let style = if annotation.is_primary { + Style::LabelPrimary + } else { + Style::LabelSecondary + }; + if annotation_id == 0 { + buffer.prepend(line_idx, " |", Style::LineNumber); + for _ in 0..max_line_num_len { + buffer.prepend(line_idx, " ", Style::NoStyle); + } + line_idx += 1; + buffer.append(line_idx + i, " = note: ", style); + for _ in 0..max_line_num_len { + buffer.prepend(line_idx, " ", Style::NoStyle); + } + } else { + buffer.append(line_idx + i, ": ", style); } - line_idx += 1; - buffer.append(line_idx + i, " = note: ", style); - for _ in 0..max_line_num_len { - buffer.prepend(line_idx, " ", Style::NoStyle); - } - } else { - buffer.append(line_idx + i, ": ", style); + buffer.append(line_idx + i, label, style); } - buffer.append(line_idx + i, label, style); } } } |
