Don't emit empty notes

This commit is contained in:
Oli Scherer 2022-12-12 12:26:16 +00:00
parent 063b1675b2
commit 2e2a4797a2
14 changed files with 20 additions and 46 deletions

View File

@ -1431,25 +1431,27 @@ impl EmitterWriter {
}; };
for (i, annotation) in annotations.into_iter().enumerate() { for (i, annotation) in annotations.into_iter().enumerate() {
if let Some(label) = &annotation.label { if let Some(label) = &annotation.label {
let style = if annotation.is_primary { if !label.is_empty() {
Style::LabelPrimary let style = if annotation.is_primary {
} else { Style::LabelPrimary
Style::LabelSecondary } else {
}; Style::LabelSecondary
if annotation_id == 0 { };
buffer.prepend(line_idx, " |", Style::LineNumber); if annotation_id == 0 {
for _ in 0..max_line_num_len { buffer.prepend(line_idx, " |", Style::LineNumber);
buffer.prepend(line_idx, " ", Style::NoStyle); 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, label, style);
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);
} }
} }
} }

View File

@ -6,8 +6,6 @@ LL | match x { }
| |
note: `Option<i32>` defined here note: `Option<i32>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL --> $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
$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>` = note: the matched value is of type `Option<i32>`

View 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: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Option<i32>` defined here note: `Option<i32>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL --> $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>` = 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 help: you might want to use `if let` to ignore the variant that isn't matched

View File

@ -6,8 +6,6 @@ LL | for Some(x) in xs {}
| |
note: `Option<i32>` defined here note: `Option<i32>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL --> $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>` = note: the matched value is of type `Option<i32>`

View 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: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Result<u32, !>` defined here note: `Result<u32, !>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL --> $SRC_DIR/core/src/result.rs:LL:COL
|
= note:
$SRC_DIR/core/src/result.rs:LL:COL: not covered $SRC_DIR/core/src/result.rs:LL:COL: not covered
= note: the matched value is of type `Result<u32, !>` = 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 help: you might want to use `if let` to ignore the variant that isn't matched

View File

@ -6,8 +6,6 @@ LL | match Some(1) {
| |
note: `Option<i32>` defined here note: `Option<i32>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL --> $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>` = 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 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown

View File

@ -66,8 +66,6 @@ LL | match None {
| |
note: `Option<HiddenEnum>` defined here note: `Option<HiddenEnum>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL --> $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<HiddenEnum>` = 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 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

View File

@ -107,8 +107,6 @@ LL | match Some(A) {
| |
note: `Option<Enum>` defined here note: `Option<Enum>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL --> $SRC_DIR/core/src/option.rs:LL:COL
|
= note:
= note: the matched value is of type `Option<Enum>` = 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 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
| |

View 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 $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>` = 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 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
| |

View File

@ -19,8 +19,6 @@ LL | match Some(Some(North)) {
| |
note: `Option<Option<Direction>>` defined here note: `Option<Option<Direction>>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL --> $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
: not covered : not covered
= note: the matched value is of type `Option<Option<Direction>>` = note: the matched value is of type `Option<Option<Direction>>`

View File

@ -6,8 +6,6 @@ LL | match private::DATA {
| |
note: `Option<Private>` defined here note: `Option<Private>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL --> $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<Private>` = 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 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown

View File

@ -36,8 +36,6 @@ LL | match Some(10) {
| |
note: `Option<i32>` defined here note: `Option<i32>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL --> $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>` = 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 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown

View 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: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Result<u32, &R<'_>>` defined here note: `Result<u32, &R<'_>>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL --> $SRC_DIR/core/src/result.rs:LL:COL
|
= note:
$SRC_DIR/core/src/result.rs:LL:COL: not covered $SRC_DIR/core/src/result.rs:LL:COL: not covered
= note: the matched value is of type `Result<u32, &R<'_>>` = 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 help: you might want to use `if let` to ignore the variant that isn't matched

View File

@ -6,8 +6,6 @@ LL | let _ = match x {
| |
note: `Result<u32, &Void>` defined here note: `Result<u32, &Void>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL --> $SRC_DIR/core/src/result.rs:LL:COL
|
= note:
$SRC_DIR/core/src/result.rs:LL:COL: not covered $SRC_DIR/core/src/result.rs:LL:COL: not covered
= note: the matched value is of type `Result<u32, &Void>` = 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 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 note: `Result<u32, Void>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL --> $SRC_DIR/core/src/result.rs:LL:COL
|
= note:
$SRC_DIR/core/src/result.rs:LL:COL: not covered $SRC_DIR/core/src/result.rs:LL:COL: not covered
= note: the matched value is of type `Result<u32, Void>` = 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 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: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Result<u32, Void>` defined here note: `Result<u32, Void>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL --> $SRC_DIR/core/src/result.rs:LL:COL
|
= note:
$SRC_DIR/core/src/result.rs:LL:COL: not covered $SRC_DIR/core/src/result.rs:LL:COL: not covered
= note: the matched value is of type `Result<u32, Void>` = 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 help: you might want to use `if let` to ignore the variant that isn't matched