From 2e2a4797a26b0effe15815b403be4ba752cc7a0b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 12 Dec 2022 12:26:16 +0000 Subject: Don't emit empty notes --- compiler/rustc_errors/src/emitter.rs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'compiler/rustc_errors') 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); } } } -- cgit 1.4.1-3-g733a5