]> git.lizzy.rs Git - rust.git/commitdiff
Don't emit empty notes
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 12 Dec 2022 12:26:16 +0000 (12:26 +0000)
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 13 Dec 2022 09:53:36 +0000 (09:53 +0000)
14 files changed:
compiler/rustc_errors/src/emitter.rs
src/test/ui/error-codes/E0004-2.stderr
src/test/ui/error-codes/E0005.stderr
src/test/ui/error-codes/E0297.stderr
src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr
src/test/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.stderr
src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr
src/test/ui/pattern/usefulness/issue-35609.stderr
src/test/ui/pattern/usefulness/issue-3601.stderr
src/test/ui/pattern/usefulness/match-arm-statics-2.stderr
src/test/ui/pattern/usefulness/match-privately-empty.stderr
src/test/ui/pattern/usefulness/non-exhaustive-match.stderr
src/test/ui/recursion/recursive-types-are-not-uninhabited.stderr
src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr

index aaf0699f0dc41b1b0784ba42670b80a1a899964f..268f17f86fe4d3d104ac04c93dc5d45e3f2d45dc 100644 (file)
@@ -1431,25 +1431,27 @@ fn emit_message_default(
                         };
                         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);
                             }
                         }
                     }
index 200b5235259e75472bbe7616853b9b731f46d247..7dd1396529bbe8805d2c7589aa7c70a02725672e 100644 (file)
@@ -6,8 +6,6 @@ LL |     match x { }
    |
 note: `Option<i32>` defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/option.rs:LL:COL: not covered
 $SRC_DIR/core/src/option.rs:LL:COL: not covered
    = note: the matched value is of type `Option<i32>`
index 762654671e092ab1032bf27142327c95cfe602c4..ef1bb60d149253b92b9e07f7280ddcde2bd390ca 100644 (file)
@@ -8,8 +8,6 @@ LL |     let Some(y) = x;
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
 note: `Option<i32>` defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/option.rs:LL:COL: not covered
    = note: the matched value is of type `Option<i32>`
 help: you might want to use `if let` to ignore the variant that isn't matched
index 4d4bdfc09e97d41039959f1d2409b5b503d64d83..5afa25dcb72a1c0051af09e8498a43b3e2ea53fc 100644 (file)
@@ -6,8 +6,6 @@ LL |     for Some(x) in xs {}
    |
 note: `Option<i32>` defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/option.rs:LL:COL: not covered
    = note: the matched value is of type `Option<i32>`
 
index fe1f247adc0572b37067440c9817fda7462122c1..b26383af72fcafe9e629d23b6c1af75904e4e6e5 100644 (file)
@@ -8,8 +8,6 @@ LL |     let Ok(_x) = foo();
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
 note: `Result<u32, !>` defined here
   --> $SRC_DIR/core/src/result.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/result.rs:LL:COL: not covered
    = note: the matched value is of type `Result<u32, !>`
 help: you might want to use `if let` to ignore the variant that isn't matched
index 635f6c86f4a5b8e3e974916f747b752f300f700b..e0c88f81eac2b78a7d8f1a0407ebcf1a3ebf4a27 100644 (file)
@@ -6,8 +6,6 @@ LL |     match Some(1) {
    |
 note: `Option<i32>` defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/option.rs:LL:COL: not covered
    = note: the matched value is of type `Option<i32>`
 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
index 610c86b3385b9c9851e16fac1d3c7c18c54d70ae..35e0661189fa1e54e083786fea6d87d9a9ee8cff 100644 (file)
@@ -66,8 +66,6 @@ LL |     match None {
    |
 note: `Option<HiddenEnum>` defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/option.rs:LL:COL: not covered
    = note: the matched value is of type `Option<HiddenEnum>`
 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
index 00dad2c8b674c09101ac9502e582451ad44316b7..12113957d6340dbc0862060d0b2072ed0ba124d4 100644 (file)
@@ -107,8 +107,6 @@ LL |     match Some(A) {
    |
 note: `Option<Enum>` defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
-   |
-   = note: 
    = note: the matched value is of type `Option<Enum>`
 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
    |
index 195703b922a6a1a11d09f9b78e45523f4666d6e3..e8cfb3e70168860aa1fd7cf2885566442eb60cc6 100644 (file)
@@ -8,7 +8,7 @@ note: `Box<ElementKind>` defined here
   --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
 $SRC_DIR/alloc/src/boxed.rs:LL:COL
 $SRC_DIR/alloc/src/boxed.rs:LL:COL
-$SRC_DIR/alloc/src/boxed.rs:LL:COL
+$SRC_DIR/alloc/src/boxed.rs:LL:COL
    = note: the matched value is of type `Box<ElementKind>`
 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
index 88277eb223f2fa9caf66aef3e0ecc757306ed6c0..36fc889910092dc79837842e61d2f3d1e2e03585 100644 (file)
@@ -19,8 +19,6 @@ LL |     match Some(Some(North)) {
    |
 note: `Option<Option<Direction>>` defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/option.rs:LL:COL: not covered
 : not covered
    = note: the matched value is of type `Option<Option<Direction>>`
index 0e1e1258110663e895de173eefcdcde412b64aba..9bb15ba8a428612938a180690883a5e9e491ade2 100644 (file)
@@ -6,8 +6,6 @@ LL |     match private::DATA {
    |
 note: `Option<Private>` defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/option.rs:LL:COL: not covered
    = note: the matched value is of type `Option<Private>`
 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
index 755333cdb7ebc0c990b2fe5c17cb26268e08d4d4..1256867a652e03b4287624f141c904c75ef47504 100644 (file)
@@ -36,8 +36,6 @@ LL |     match Some(10) {
    |
 note: `Option<i32>` defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/option.rs:LL:COL: not covered
    = note: the matched value is of type `Option<i32>`
 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
index 8aaaa29831843eb2aa5896cf01370c5fb375761a..429f0460e89e1664fdb010ed225683eef81645d3 100644 (file)
@@ -8,8 +8,6 @@ LL |     let Ok(x) = res;
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
 note: `Result<u32, &R<'_>>` defined here
   --> $SRC_DIR/core/src/result.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/result.rs:LL:COL: not covered
    = note: the matched value is of type `Result<u32, &R<'_>>`
 help: you might want to use `if let` to ignore the variant that isn't matched
index 44d485c47cd10e003c276eb4f6b3bbc32c67955d..c375fd62877f925900112f0fa290f18971b4fbd0 100644 (file)
@@ -6,8 +6,6 @@ LL |     let _ = match x {
    |
 note: `Result<u32, &Void>` defined here
   --> $SRC_DIR/core/src/result.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/result.rs:LL:COL: not covered
    = note: the matched value is of type `Result<u32, &Void>`
 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
@@ -85,8 +83,6 @@ LL |     let _ = match x {
    |
 note: `Result<u32, Void>` defined here
   --> $SRC_DIR/core/src/result.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/result.rs:LL:COL: not covered
    = note: the matched value is of type `Result<u32, Void>`
 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
@@ -105,8 +101,6 @@ LL |     let Ok(x) = x;
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
 note: `Result<u32, Void>` defined here
   --> $SRC_DIR/core/src/result.rs:LL:COL
-   |
-   = note: 
 $SRC_DIR/core/src/result.rs:LL:COL: not covered
    = note: the matched value is of type `Result<u32, Void>`
 help: you might want to use `if let` to ignore the variant that isn't matched