]> git.lizzy.rs Git - rust.git/commitdiff
Update E0004 to use labels
authorTheZoq2 <frans.skarman@gmail.com>
Fri, 5 Aug 2016 19:00:23 +0000 (21:00 +0200)
committerTheZoq2 <frans.skarman@gmail.com>
Fri, 5 Aug 2016 19:07:34 +0000 (21:07 +0200)
src/librustc_const_eval/check_match.rs
src/test/compile-fail/non-exhaustive-pattern-witness.rs

index d3952de2fbe30eb1088c6cbaf1df0515d5264419..07e0cece469a36355dd5fb1c030391d562c7429c 100644 (file)
@@ -423,10 +423,15 @@ fn check_exhaustive<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>,
                             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();
                 },
             }
         }
index 0b12a9acbcb9e9d56de662b81d4234bda7fc35a7..eba61ede8cb20e673e945fbe6c19e8c6043f0422 100644 (file)
@@ -19,6 +19,7 @@ struct Foo {
 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 } => (),
@@ -35,6 +36,7 @@ enum Color {
 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 => ()
     }
@@ -47,6 +49,7 @@ enum Direction {
 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 => ()
     }
 }
@@ -58,6 +61,7 @@ enum ExcessiveEnum {
 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 => ()
     }
@@ -66,6 +70,7 @@ fn enum_with_excessive_missing_variants() {
 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 } => (),
@@ -82,6 +87,7 @@ fn vectors_with_nested_enums() {
     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, _] => (),
@@ -95,6 +101,7 @@ fn vectors_with_nested_enums() {
 fn missing_nil() {
     match ((), false) {
     //~^ ERROR non-exhaustive patterns: `((), false)` not covered
+    //~| NOTE pattern `((), false)` not covered
         ((), true) => ()
     }
 }