about summary refs log tree commit diff
diff options
context:
space:
mode:
authoraclarry <admclarry@gmail.com>2016-09-16 00:10:32 -0400
committeraclarry <admclarry@gmail.com>2016-09-20 16:59:48 -0400
commit23efc5453d2c43ac143cf5d4a695b9fd9e8c695d (patch)
treefb56780cfe41fec9344eb033745918f32c13bdc1
parentaf67f0b389abca6851bbed78f25046a8c783d6b3 (diff)
downloadrust-23efc5453d2c43ac143cf5d4a695b9fd9e8c695d.tar.gz
rust-23efc5453d2c43ac143cf5d4a695b9fd9e8c695d.zip
Update E0560 to include label
-rw-r--r--src/librustc_typeck/check/mod.rs13
-rw-r--r--src/test/compile-fail/E0559.rs2
-rw-r--r--src/test/compile-fail/E0560.rs4
-rw-r--r--src/test/compile-fail/issue-19922.rs1
-rw-r--r--src/test/compile-fail/numeric-fields.rs8
-rw-r--r--src/test/compile-fail/struct-fields-hints-no-dupe.rs2
-rw-r--r--src/test/compile-fail/struct-fields-hints.rs2
-rw-r--r--src/test/compile-fail/struct-fields-too-many.rs4
-rw-r--r--src/test/compile-fail/suggest-private-fields.rs8
-rw-r--r--src/test/compile-fail/union/union-fields.rs2
-rw-r--r--src/test/compile-fail/union/union-suggest-field.rs2
11 files changed, 35 insertions, 13 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index baa084212a2..7c9467bc5fe 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -3094,7 +3094,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
         if let Some(field_name) = Self::suggest_field_name(variant,
                                                            &field.name,
                                                            skip_fields.collect()) {
-            err.span_label(field.name.span,&format!("did you mean `{}`?",field_name));
+            err.span_label(field.name.span,
+                           &format!("field does not exist - did you mean `{}`?", field_name));
+        } else {
+            match ty.sty {
+                ty::TyAdt(adt, ..) if adt.is_enum() => {
+                    err.span_label(field.name.span, &format!("`{}::{}` does not have this field",
+                                                             ty, variant.name.as_str()));
+                }
+                _ => {
+                    err.span_label(field.name.span, &format!("`{}` does not have this field", ty));
+                }
+            }
         };
         err.emit();
     }
diff --git a/src/test/compile-fail/E0559.rs b/src/test/compile-fail/E0559.rs
index aeeeae42228..fa6c885843e 100644
--- a/src/test/compile-fail/E0559.rs
+++ b/src/test/compile-fail/E0559.rs
@@ -15,5 +15,5 @@ enum Field {
 fn main() {
     let s = Field::Fool { joke: 0 };
     //~^ ERROR E0559
-    //~| NOTE did you mean `x`?
+    //~| NOTE field does not exist - did you mean `x`?
 }
diff --git a/src/test/compile-fail/E0560.rs b/src/test/compile-fail/E0560.rs
index ec9b86ee1f0..c6326a0f977 100644
--- a/src/test/compile-fail/E0560.rs
+++ b/src/test/compile-fail/E0560.rs
@@ -13,5 +13,7 @@ struct Simba {
 }
 
 fn main() {
-    let s = Simba { mother: 1, father: 0 }; //~ ERROR E0560
+    let s = Simba { mother: 1, father: 0 };
+    //~^ ERROR E0560
+    //~| NOTE `Simba` does not have this field
 }
diff --git a/src/test/compile-fail/issue-19922.rs b/src/test/compile-fail/issue-19922.rs
index a8350fe0986..d7b2f2b3f99 100644
--- a/src/test/compile-fail/issue-19922.rs
+++ b/src/test/compile-fail/issue-19922.rs
@@ -15,4 +15,5 @@ enum Homura {
 fn main() {
     let homura = Homura::Akemi { kaname: () };
     //~^ ERROR variant `Homura::Akemi` has no field named `kaname`
+    //~| NOTE field does not exist - did you mean `madoka`?
 }
diff --git a/src/test/compile-fail/numeric-fields.rs b/src/test/compile-fail/numeric-fields.rs
index c4aff9471b8..a67707257d2 100644
--- a/src/test/compile-fail/numeric-fields.rs
+++ b/src/test/compile-fail/numeric-fields.rs
@@ -13,8 +13,12 @@
 struct S(u8, u16);
 
 fn main() {
-    let s = S{0b1: 10, 0: 11}; //~ ERROR struct `S` has no field named `0b1`
+    let s = S{0b1: 10, 0: 11};
+    //~^ ERROR struct `S` has no field named `0b1`
+    //~| NOTE field does not exist - did you mean `1`?
     match s {
-        S{0: a, 0x1: b, ..} => {} //~ ERROR does not have a field named `0x1`
+        S{0: a, 0x1: b, ..} => {}
+        //~^ ERROR does not have a field named `0x1`
+        //~| NOTE struct `S::{{constructor}}` does not have field `0x1`
     }
 }
diff --git a/src/test/compile-fail/struct-fields-hints-no-dupe.rs b/src/test/compile-fail/struct-fields-hints-no-dupe.rs
index f25f01af33f..de78503d904 100644
--- a/src/test/compile-fail/struct-fields-hints-no-dupe.rs
+++ b/src/test/compile-fail/struct-fields-hints-no-dupe.rs
@@ -19,7 +19,7 @@ fn main() {
         foo : 5,
         bar : 42,
         //~^ ERROR struct `A` has no field named `bar`
-        //~| NOTE did you mean `barr`?
+        //~| NOTE field does not exist - did you mean `barr`?
         car : 9,
     };
 }
diff --git a/src/test/compile-fail/struct-fields-hints.rs b/src/test/compile-fail/struct-fields-hints.rs
index 62ec6e6b0d2..628f03f3272 100644
--- a/src/test/compile-fail/struct-fields-hints.rs
+++ b/src/test/compile-fail/struct-fields-hints.rs
@@ -19,6 +19,6 @@ fn main() {
         foo : 5,
         bar : 42,
         //~^ ERROR struct `A` has no field named `bar`
-        //~| NOTE did you mean `car`?
+        //~| NOTE field does not exist - did you mean `car`?
     };
 }
diff --git a/src/test/compile-fail/struct-fields-too-many.rs b/src/test/compile-fail/struct-fields-too-many.rs
index 5d16573f2f1..0848ada731a 100644
--- a/src/test/compile-fail/struct-fields-too-many.rs
+++ b/src/test/compile-fail/struct-fields-too-many.rs
@@ -15,6 +15,8 @@ struct BuildData {
 fn main() {
     let foo = BuildData {
         foo: 0,
-        bar: 0 //~ ERROR struct `BuildData` has no field named `bar`
+        bar: 0
+        //~^ ERROR struct `BuildData` has no field named `bar`
+        //~| NOTE `BuildData` does not have this field
     };
 }
diff --git a/src/test/compile-fail/suggest-private-fields.rs b/src/test/compile-fail/suggest-private-fields.rs
index 906bfc78498..3672e0e90c2 100644
--- a/src/test/compile-fail/suggest-private-fields.rs
+++ b/src/test/compile-fail/suggest-private-fields.rs
@@ -24,18 +24,18 @@ fn main () {
     let k = B {
         aa: 20,
         //~^ ERROR struct `xc::B` has no field named `aa`
-        //~| NOTE did you mean `a`?
+        //~| NOTE field does not exist - did you mean `a`?
         bb: 20,
         //~^ ERROR struct `xc::B` has no field named `bb`
-        //~| NOTE did you mean `a`?
+        //~| NOTE field does not exist - did you mean `a`?
     };
     // local crate struct
     let l = A {
         aa: 20,
         //~^ ERROR struct `A` has no field named `aa`
-        //~| NOTE did you mean `a`?
+        //~| NOTE field does not exist - did you mean `a`?
         bb: 20,
         //~^ ERROR struct `A` has no field named `bb`
-        //~| NOTE did you mean `b`?
+        //~| NOTE field does not exist - did you mean `b`?
     };
 }
diff --git a/src/test/compile-fail/union/union-fields.rs b/src/test/compile-fail/union/union-fields.rs
index a1721dda7de..3ee95c2ef42 100644
--- a/src/test/compile-fail/union/union-fields.rs
+++ b/src/test/compile-fail/union/union-fields.rs
@@ -21,6 +21,7 @@ fn main() {
     let u = U { a: 0, b: 1 }; //~ ERROR union expressions should have exactly one field
     let u = U { a: 0, b: 1, c: 2 }; //~ ERROR union expressions should have exactly one field
                                     //~^ ERROR union `U` has no field named `c`
+                                    //~| NOTE `U` does not have this field
     let u = U { ..u }; //~ ERROR union expressions should have exactly one field
                        //~^ ERROR functional record update syntax requires a struct
 
@@ -29,6 +30,7 @@ fn main() {
     let U { a, b } = u; //~ ERROR union patterns should have exactly one field
     let U { a, b, c } = u; //~ ERROR union patterns should have exactly one field
                            //~^ ERROR union `U` does not have a field named `c`
+                           //~| NOTE union `U` does not have field `c`
     let U { .. } = u; //~ ERROR union patterns should have exactly one field
                       //~^ ERROR `..` cannot be used in union patterns
     let U { a, .. } = u; //~ ERROR `..` cannot be used in union patterns
diff --git a/src/test/compile-fail/union/union-suggest-field.rs b/src/test/compile-fail/union/union-suggest-field.rs
index 92811b6b5be..ce421428d88 100644
--- a/src/test/compile-fail/union/union-suggest-field.rs
+++ b/src/test/compile-fail/union/union-suggest-field.rs
@@ -21,7 +21,7 @@ impl U {
 fn main() {
     let u = U { principle: 0 };
     //~^ ERROR union `U` has no field named `principle`
-    //~| NOTE did you mean `principal`?
+    //~| NOTE field does not exist - did you mean `principal`?
     let w = u.principial; //~ ERROR attempted access of field `principial` on type `U`
                           //~^ HELP did you mean `principal`?