]> git.lizzy.rs Git - rust.git/commitdiff
Properly indent messages
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 29 Nov 2022 13:35:13 +0000 (13:35 +0000)
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 6 Dec 2022 18:59:46 +0000 (18:59 +0000)
compiler/rustc_errors/src/emitter.rs
src/test/ui/consts/missing_span_in_backtrace.stderr
src/test/ui/span/issue-71363.stderr

index 7e1effd83789c370815fca697cdf72f7bb668489..4df2198fb0e9bc8eaad61d0babc663efe6e6bd72 100644 (file)
@@ -1408,7 +1408,7 @@ fn emit_message_default(
             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 @@ fn emit_message_default(
                             ),
                             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 @@ fn emit_message_default(
                                 } 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);
                             }
                         }
index f2a79a1d3d34cebe36b89005c247bf804f33ea58..b8c20df8700fa6bc18a4c7d2facfdd09784a72cc 100644 (file)
@@ -1,16 +1,18 @@
 error[E0080]: evaluation of constant value failed
-/rustc/xyz/library/core/src/ptr/mod.rs:1135:9: unable to copy parts of a pointer from memory at alloc10
+  --> /rustc/xyz/library/core/src/ptr/mod.rs:1135:9
+   |
+   = note: unable to copy parts of a pointer from memory at alloc10
    |
    = help: this code performed an operation that depends on the underlying bytes representing a pointer
    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
 note: inside `std::ptr::read::<MaybeUninit<MaybeUninit<u8>>>`
-/rustc/xyz/library/core/src/ptr/mod.rs:1135:9
+  --> /rustc/xyz/library/core/src/ptr/mod.rs:1135:9
 note: inside `mem::swap_simple::<MaybeUninit<MaybeUninit<u8>>>`
-/rustc/xyz/library/core/src/mem/mod.rs:773:17
+  --> /rustc/xyz/library/core/src/mem/mod.rs:773:17
 note: inside `ptr::swap_nonoverlapping_simple_untyped::<MaybeUninit<u8>>`
-/rustc/xyz/library/core/src/ptr/mod.rs:944:9
+  --> /rustc/xyz/library/core/src/ptr/mod.rs:944:9
 note: inside `swap_nonoverlapping::<MaybeUninit<u8>>`
-/rustc/xyz/library/core/src/ptr/mod.rs:925:14
+  --> /rustc/xyz/library/core/src/ptr/mod.rs:925:14
 note: inside `X`
   --> $DIR/missing_span_in_backtrace.rs:16:9
    |
index c0268ec683f74deb8452b6cc08f0cdcde10888bf..789a386bf66d1c6abff43351c1b82674308db56a 100644 (file)
@@ -7,7 +7,9 @@ error[E0277]: `MyError` doesn't implement `std::fmt::Display`
   = help: the trait `std::fmt::Display` is not implemented for `MyError`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
 note: required by a bound in `std::error::Error`
-/rustc/xyz/library/core/src/error.rs:31:26: required by this bound in `std::error::Error`
+ --> /rustc/xyz/library/core/src/error.rs:31:26
+  |
+  = note: required by this bound in `std::error::Error`
 
 error[E0277]: `MyError` doesn't implement `Debug`
  --> $DIR/issue-71363.rs:4:6
@@ -18,7 +20,9 @@ error[E0277]: `MyError` doesn't implement `Debug`
   = help: the trait `Debug` is not implemented for `MyError`
   = note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError`
 note: required by a bound in `std::error::Error`
-/rustc/xyz/library/core/src/error.rs:31:18: required by this bound in `std::error::Error`
+ --> /rustc/xyz/library/core/src/error.rs:31:18
+  |
+  = note: required by this bound in `std::error::Error`
 help: consider annotating `MyError` with `#[derive(Debug)]`
   |
 3 | #[derive(Debug)]