format!("`{}` and {} more", head.join("`, `"), tail.len())
}
};
- span_err!(cx.tcx.sess, sp, E0004,
+
+ let label_text = match pattern_strings.len(){
+ 1 => format!("pattern {} not covered", joined_patterns),
+ _ => format!("patterns {} not covered", joined_patterns)
+ };
+ struct_span_err!(cx.tcx.sess, sp, E0004,
"non-exhaustive patterns: {} not covered",
joined_patterns
- );
+ ).span_label(sp, &label_text).emit();
},
}
}
fn struct_with_a_nested_enum_and_vector() {
match (Foo { first: true, second: None }) {
//~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered
+//~| NOTE pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered
Foo { first: true, second: None } => (),
Foo { first: true, second: Some(_) } => (),
Foo { first: false, second: None } => (),
fn enum_with_single_missing_variant() {
match Color::Red {
//~^ ERROR non-exhaustive patterns: `Red` not covered
+ //~| NOTE pattern `Red` not covered
Color::CustomRGBA { .. } => (),
Color::Green => ()
}
fn enum_with_multiple_missing_variants() {
match Direction::North {
//~^ ERROR non-exhaustive patterns: `East`, `South` and `West` not covered
+ //~| NOTE patterns `East`, `South` and `West` not covered
Direction::North => ()
}
}
fn enum_with_excessive_missing_variants() {
match ExcessiveEnum::First {
//~^ ERROR `Second`, `Third`, `Fourth` and 8 more not covered
+ //~| NOTE patterns `Second`, `Third`, `Fourth` and 8 more not covered
ExcessiveEnum::First => ()
}
fn enum_struct_variant() {
match Color::Red {
//~^ ERROR non-exhaustive patterns: `CustomRGBA { a: true, .. }` not covered
+ //~| NOTE pattern `CustomRGBA { a: true, .. }` not covered
Color::Red => (),
Color::Green => (),
Color::CustomRGBA { a: false, r: _, g: _, b: 0 } => (),
let x: &'static [Enum] = &[Enum::First, Enum::Second(false)];
match *x {
//~^ ERROR non-exhaustive patterns: `[Second(true), Second(false)]` not covered
+ //~| NOTE pattern `[Second(true), Second(false)]` not covered
[] => (),
[_] => (),
[Enum::First, _] => (),
fn missing_nil() {
match ((), false) {
//~^ ERROR non-exhaustive patterns: `((), false)` not covered
+ //~| NOTE pattern `((), false)` not covered
((), true) => ()
}
}