diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-29 13:35:13 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-06 18:59:46 +0000 |
| commit | f89d6236aa60ddc955c1f4dd778e9b8abba9ad9a (patch) | |
| tree | 2e659a0de4beb8563333c75651127d00a2cbdead /compiler/rustc_errors/src | |
| parent | 99348a5330cb4d6e3bb2e28badebd76561b8996f (diff) | |
| download | rust-f89d6236aa60ddc955c1f4dd778e9b8abba9ad9a.tar.gz rust-f89d6236aa60ddc955c1f4dd778e9b8abba9ad9a.zip | |
Properly indent messages
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 7e1effd8378..4df2198fb0e 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1408,7 +1408,7 @@ impl EmitterWriter { if !sm.ensure_source_file_source_present(annotated_file.file.clone()) { if !self.short_message { // We'll just print an unannotated message. - for line in annotated_file.lines { + for (annotation_id, line) in annotated_file.lines.into_iter().enumerate() { let mut annotations = line.annotations.clone(); annotations.sort_by_key(|a| Reverse(a.start_col)); let mut line_idx = buffer.num_lines(); @@ -1422,12 +1422,12 @@ impl EmitterWriter { ), Style::LineAndColumn, ); - let prefix = if annotations.len() > 1 { + 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; - "note: " - } else { - ": " }; for (i, annotation) in annotations.into_iter().enumerate() { if let Some(label) = &annotation.label { @@ -1436,7 +1436,19 @@ impl EmitterWriter { } else { Style::LabelSecondary }; - buffer.append(line_idx + i, prefix, style); + 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); + } buffer.append(line_idx + i, label, style); } } |
