Skip to content

Commit 67f0822

Browse files
authoredAug 6, 2016
Rollup merge of #35380 - TheZoq2:master, r=jonathandturner
Update E0004 to use labels Fixes #35191 and is part of #35233 "r? @jonathandturner
2 parents 56cadb6 + 422e0d5 commit 67f0822

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed
 

‎src/librustc_const_eval/check_match.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,15 @@ fn check_exhaustive<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>,
424424
format!("`{}` and {} more", head.join("`, `"), tail.len())
425425
}
426426
};
427-
span_err!(cx.tcx.sess, sp, E0004,
427+
428+
let label_text = match pattern_strings.len(){
429+
1 => format!("pattern {} not covered", joined_patterns),
430+
_ => format!("patterns {} not covered", joined_patterns)
431+
};
432+
struct_span_err!(cx.tcx.sess, sp, E0004,
428433
"non-exhaustive patterns: {} not covered",
429434
joined_patterns
430-
);
435+
).span_label(sp, &label_text).emit();
431436
},
432437
}
433438
}

‎src/test/compile-fail/non-exhaustive-pattern-witness.rs

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct Foo {
1919
fn struct_with_a_nested_enum_and_vector() {
2020
match (Foo { first: true, second: None }) {
2121
//~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered
22+
//~| NOTE pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered
2223
Foo { first: true, second: None } => (),
2324
Foo { first: true, second: Some(_) } => (),
2425
Foo { first: false, second: None } => (),
@@ -35,6 +36,7 @@ enum Color {
3536
fn enum_with_single_missing_variant() {
3637
match Color::Red {
3738
//~^ ERROR non-exhaustive patterns: `Red` not covered
39+
//~| NOTE pattern `Red` not covered
3840
Color::CustomRGBA { .. } => (),
3941
Color::Green => ()
4042
}
@@ -47,6 +49,7 @@ enum Direction {
4749
fn enum_with_multiple_missing_variants() {
4850
match Direction::North {
4951
//~^ ERROR non-exhaustive patterns: `East`, `South` and `West` not covered
52+
//~| NOTE patterns `East`, `South` and `West` not covered
5053
Direction::North => ()
5154
}
5255
}
@@ -58,6 +61,7 @@ enum ExcessiveEnum {
5861
fn enum_with_excessive_missing_variants() {
5962
match ExcessiveEnum::First {
6063
//~^ ERROR `Second`, `Third`, `Fourth` and 8 more not covered
64+
//~| NOTE patterns `Second`, `Third`, `Fourth` and 8 more not covered
6165

6266
ExcessiveEnum::First => ()
6367
}
@@ -66,6 +70,7 @@ fn enum_with_excessive_missing_variants() {
6670
fn enum_struct_variant() {
6771
match Color::Red {
6872
//~^ ERROR non-exhaustive patterns: `CustomRGBA { a: true, .. }` not covered
73+
//~| NOTE pattern `CustomRGBA { a: true, .. }` not covered
6974
Color::Red => (),
7075
Color::Green => (),
7176
Color::CustomRGBA { a: false, r: _, g: _, b: 0 } => (),
@@ -82,6 +87,7 @@ fn vectors_with_nested_enums() {
8287
let x: &'static [Enum] = &[Enum::First, Enum::Second(false)];
8388
match *x {
8489
//~^ ERROR non-exhaustive patterns: `[Second(true), Second(false)]` not covered
90+
//~| NOTE pattern `[Second(true), Second(false)]` not covered
8591
[] => (),
8692
[_] => (),
8793
[Enum::First, _] => (),
@@ -95,6 +101,7 @@ fn vectors_with_nested_enums() {
95101
fn missing_nil() {
96102
match ((), false) {
97103
//~^ ERROR non-exhaustive patterns: `((), false)` not covered
104+
//~| NOTE pattern `((), false)` not covered
98105
((), true) => ()
99106
}
100107
}

0 commit comments

Comments
 (0)
Please sign in to comment.