about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2016-09-15 00:51:46 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2016-10-04 22:20:38 +0300
commitc95b280d723ae6a6243b04ac06be100c622634b4 (patch)
tree449ab65d7711169fbb3d4fce93ff6ac2f441857e
parente8ea38e42a7e361e37b1cd3622f3baf1c8055986 (diff)
downloadrust-c95b280d723ae6a6243b04ac06be100c622634b4.tar.gz
rust-c95b280d723ae6a6243b04ac06be100c622634b4.zip
Move pattern resolution checks from typeck to resolve
Make error messages more precise
-rw-r--r--src/librustc/hir/def.rs10
-rw-r--r--src/librustc_resolve/lib.rs31
-rw-r--r--src/librustc_typeck/check/_match.rs68
-rw-r--r--src/test/compile-fail/E0164.rs8
-rw-r--r--src/test/compile-fail/blind-item-block-middle.rs2
-rw-r--r--src/test/compile-fail/empty-struct-braces-pat-1.rs4
-rw-r--r--src/test/compile-fail/empty-struct-braces-pat-2.rs8
-rw-r--r--src/test/compile-fail/empty-struct-braces-pat-3.rs12
-rw-r--r--src/test/compile-fail/empty-struct-tuple-pat.rs10
-rw-r--r--src/test/compile-fail/empty-struct-unit-pat-1.rs11
-rw-r--r--src/test/compile-fail/empty-struct-unit-pat-2.rs13
-rw-r--r--src/test/compile-fail/enum-in-scope.rs2
-rw-r--r--src/test/compile-fail/enums-pats-not-idents.rs2
-rw-r--r--src/test/compile-fail/issue-10200.rs2
-rw-r--r--src/test/compile-fail/issue-12863.rs2
-rw-r--r--src/test/compile-fail/issue-17933.rs2
-rw-r--r--src/test/compile-fail/issue-19086.rs2
-rw-r--r--src/test/compile-fail/issue-27033.rs2
-rw-r--r--src/test/compile-fail/issue-27815.rs6
-rw-r--r--src/test/compile-fail/issue-28992-empty.rs5
-rw-r--r--src/test/compile-fail/issue-32004.rs4
-rw-r--r--src/test/compile-fail/issue-32086.rs4
-rw-r--r--src/test/compile-fail/issue-5927.rs2
-rw-r--r--src/test/compile-fail/match-pattern-field-mismatch-2.rs2
-rw-r--r--src/test/compile-fail/match-pattern-field-mismatch.rs2
-rw-r--r--src/test/compile-fail/method-path-in-pattern.rs6
-rw-r--r--src/test/compile-fail/method-resolvable-path-in-pattern.rs2
-rw-r--r--src/test/compile-fail/name-clash-nullary.rs2
-rw-r--r--src/test/compile-fail/pat-shadow-in-nested-binding.rs2
-rw-r--r--src/test/compile-fail/pat-tuple-overfield.rs4
-rw-r--r--src/test/compile-fail/pattern-error-continue.rs2
-rw-r--r--src/test/compile-fail/qualified-path-params.rs2
-rw-r--r--src/test/compile-fail/xcrate-private-by-default.rs2
33 files changed, 125 insertions, 113 deletions
diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs
index 94ce6e2f7f7..33282f5b3e9 100644
--- a/src/librustc/hir/def.rs
+++ b/src/librustc/hir/def.rs
@@ -140,12 +140,16 @@ impl Def {
             Def::Mod(..) => "module",
             Def::Static(..) => "static",
             Def::Variant(..) => "variant",
-            Def::VariantCtor(..) => "variant",
+            Def::VariantCtor(.., CtorKind::Fn) => "tuple variant",
+            Def::VariantCtor(.., CtorKind::Const) => "unit variant",
+            Def::VariantCtor(.., CtorKind::Fictive) => "struct variant",
             Def::Enum(..) => "enum",
-            Def::TyAlias(..) => "type",
+            Def::TyAlias(..) => "type alias",
             Def::AssociatedTy(..) => "associated type",
             Def::Struct(..) => "struct",
-            Def::StructCtor(..) => "struct",
+            Def::StructCtor(.., CtorKind::Fn) => "tuple struct",
+            Def::StructCtor(.., CtorKind::Const) => "unit struct",
+            Def::StructCtor(.., CtorKind::Fictive) => bug!("impossible struct constructor"),
             Def::Union(..) => "union",
             Def::Trait(..) => "trait",
             Def::Method(..) => "method",
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 3dbe4d91536..49e7f3ba19c 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -485,7 +485,7 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
                              E0531,
                              "unresolved {} `{}`",
                              expected_what,
-                             path.segments.last().unwrap().identifier)
+                             path)
         }
         ResolutionError::PatPathUnexpected(expected_what, found_what, path) => {
             struct_span_err!(resolver.session,
@@ -494,7 +494,7 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
                              "expected {}, found {} `{}`",
                              expected_what,
                              found_what,
-                             path.segments.last().unwrap().identifier)
+                             path)
         }
     }
 }
@@ -2376,15 +2376,16 @@ impl<'a> Resolver<'a> {
                         let always_binding = !pat_src.is_refutable() || opt_pat.is_some() ||
                                              bmode != BindingMode::ByValue(Mutability::Immutable);
                         match def {
-                            Def::StructCtor(..) | Def::VariantCtor(..) |
-                            Def::Const(..) | Def::AssociatedConst(..) if !always_binding => {
-                                // A constant, unit variant, etc pattern.
+                            Def::StructCtor(_, CtorKind::Const) |
+                            Def::VariantCtor(_, CtorKind::Const) |
+                            Def::Const(..) if !always_binding => {
+                                // A unit struct/variant or constant pattern.
                                 let name = ident.node.name;
                                 self.record_use(name, ValueNS, binding.unwrap(), ident.span);
                                 Some(PathResolution::new(def))
                             }
                             Def::StructCtor(..) | Def::VariantCtor(..) |
-                            Def::Const(..) | Def::AssociatedConst(..) | Def::Static(..) => {
+                            Def::Const(..) | Def::Static(..) => {
                                 // A fresh binding that shadows something unacceptable.
                                 resolve_error(
                                     self,
@@ -2401,7 +2402,7 @@ impl<'a> Resolver<'a> {
                             }
                             def => {
                                 span_bug!(ident.span, "unexpected definition for an \
-                                                       identifier in pattern {:?}", def);
+                                                       identifier in pattern: {:?}", def);
                             }
                         }
                     }).unwrap_or_else(|| {
@@ -2411,23 +2412,29 @@ impl<'a> Resolver<'a> {
                     self.record_def(pat.id, resolution);
                 }
 
-                PatKind::TupleStruct(ref path, ..) => {
+                PatKind::TupleStruct(ref path, ref pats, ddpos) => {
                     self.resolve_pattern_path(pat.id, None, path, ValueNS, |def| {
                         match def {
-                            Def::StructCtor(..) | Def::VariantCtor(..) => true,
+                            Def::StructCtor(_, CtorKind::Fn) |
+                            Def::VariantCtor(_, CtorKind::Fn) => true,
+                            // `UnitVariant(..)` is accepted for backward compatibility.
+                            Def::StructCtor(_, CtorKind::Const) |
+                            Def::VariantCtor(_, CtorKind::Const)
+                                if pats.is_empty() && ddpos.is_some() => true,
                             _ => false,
                         }
-                    }, "variant or struct");
+                    }, "tuple struct/variant");
                 }
 
                 PatKind::Path(ref qself, ref path) => {
                     self.resolve_pattern_path(pat.id, qself.as_ref(), path, ValueNS, |def| {
                         match def {
-                            Def::StructCtor(..) | Def::VariantCtor(..) |
+                            Def::StructCtor(_, CtorKind::Const) |
+                            Def::VariantCtor(_, CtorKind::Const) |
                             Def::Const(..) | Def::AssociatedConst(..) => true,
                             _ => false,
                         }
-                    }, "variant, struct or constant");
+                    }, "unit struct/variant or constant");
                 }
 
                 PatKind::Struct(ref path, ..) => {
diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs
index cc99ee63ad9..27491c6dfce 100644
--- a/src/librustc_typeck/check/_match.rs
+++ b/src/librustc_typeck/check/_match.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use hir::def::Def;
+use rustc::hir::{self, PatKind};
+use rustc::hir::def::{Def, CtorKind};
+use rustc::hir::pat_util::EnumerateAndAdjustIterator;
 use rustc::infer::{self, InferOk, TypeOrigin};
-use hir::pat_util::EnumerateAndAdjustIterator;
-use rustc::ty::{self, Ty, TypeFoldable, LvaluePreference, VariantKind};
+use rustc::ty::{self, Ty, TypeFoldable, LvaluePreference};
 use check::{FnCtxt, Expectation};
 use lint;
 use util::nodemap::FnvHashMap;
@@ -23,9 +24,6 @@ use syntax::codemap::Spanned;
 use syntax::ptr::P;
 use syntax_pos::Span;
 
-use rustc::hir::{self, PatKind};
-use rustc::hir::print as pprust;
-
 impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
     pub fn check_pat(&self, pat: &'gcx hir::Pat, expected: Ty<'tcx>) {
         let tcx = self.tcx;
@@ -516,10 +514,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                       expected: Ty<'tcx>) -> Ty<'tcx>
     {
         let tcx = self.tcx;
-        let report_unexpected_def = || {
+        let report_unexpected_def = |def: Def| {
             span_err!(tcx.sess, pat.span, E0533,
-                      "`{}` does not name a unit variant, unit struct or a constant",
-                      pprust::path_to_string(path));
+                      "expected unit struct/variant or constant, found {} `{}`",
+                      def.kind_name(), path);
         };
 
         // Resolve the path and check the definition for errors.
@@ -531,18 +529,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 return tcx.types.err;
             }
             Def::Method(..) => {
-                report_unexpected_def();
+                report_unexpected_def(def);
                 return tcx.types.err;
             }
-            Def::VariantCtor(..) | Def::StructCtor(..) => {
-                let variant = tcx.expect_variant_def(def);
-                if variant.kind != VariantKind::Unit {
-                    report_unexpected_def();
-                    return tcx.types.err;
-                }
-            }
+            Def::VariantCtor(_, CtorKind::Const) |
+            Def::StructCtor(_, CtorKind::Const) |
             Def::Const(..) | Def::AssociatedConst(..) => {} // OK
-            _ => bug!("unexpected pattern definition {:?}", def)
+            _ => bug!("unexpected pattern definition: {:?}", def)
         }
 
         // Type check the path.
@@ -564,9 +557,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 self.check_pat(&pat, tcx.types.err);
             }
         };
-        let report_unexpected_def = |is_lint| {
-            let msg = format!("`{}` does not name a tuple variant or a tuple struct",
-                              pprust::path_to_string(path));
+        let report_unexpected_def = |def: Def, is_lint| {
+            let msg = format!("expected tuple struct/variant, found {} `{}`",
+                              def.kind_name(), path);
             if is_lint {
                 tcx.sess.add_lint(lint::builtin::MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT,
                                   pat.id, pat.span, msg);
@@ -585,23 +578,20 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 on_error();
                 return tcx.types.err;
             }
-            Def::Const(..) | Def::AssociatedConst(..) | Def::Method(..) => {
-                report_unexpected_def(false);
+            Def::AssociatedConst(..) | Def::Method(..) => {
+                report_unexpected_def(def, false);
                 return tcx.types.err;
             }
-            Def::VariantCtor(..) | Def::StructCtor(..) => {
+            Def::VariantCtor(_, ctor_kind) | Def::StructCtor(_, ctor_kind) => {
+                if ctor_kind == CtorKind::Const {
+                    // Matching unit structs with tuple variant patterns (`UnitVariant(..)`)
+                    // is allowed for backward compatibility.
+                    report_unexpected_def(def, true);
+                }
                 tcx.expect_variant_def(def)
             }
-            _ => bug!("unexpected pattern definition {:?}", def)
+            _ => bug!("unexpected pattern definition: {:?}", def)
         };
-        if variant.kind == VariantKind::Unit && subpats.is_empty() && ddpos.is_some() {
-            // Matching unit structs with tuple variant patterns (`UnitVariant(..)`)
-            // is allowed for backward compatibility.
-            report_unexpected_def(true);
-        } else if variant.kind != VariantKind::Tuple {
-            report_unexpected_def(false);
-            return tcx.types.err;
-        }
 
         // Type check the path.
         let pat_ty = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.id);
@@ -626,16 +616,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 self.check_pat(&subpat, field_ty);
             }
         } else {
-            let subpats_ending = if subpats.len() == 1 {
-                ""
-            } else {
-                "s"
-            };
-            let fields_ending = if variant.fields.len() == 1 {
-                ""
-            } else {
-                "s"
-            };
+            let subpats_ending = if subpats.len() == 1 { "" } else { "s" };
+            let fields_ending = if variant.fields.len() == 1 { "" } else { "s" };
             struct_span_err!(tcx.sess, pat.span, E0023,
                              "this pattern has {} field{}, but the corresponding {} has {} field{}",
                              subpats.len(), subpats_ending, def.kind_name(),
diff --git a/src/test/compile-fail/E0164.rs b/src/test/compile-fail/E0164.rs
index 1665a80bead..8d21cde84da 100644
--- a/src/test/compile-fail/E0164.rs
+++ b/src/test/compile-fail/E0164.rs
@@ -8,7 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-enum Foo { B { i: u32 } }
+#![feature(associated_consts)]
+
+enum Foo {}
+
+impl Foo {
+    const B: u8 = 0;
+}
 
 fn bar(foo: Foo) -> u32 {
     match foo {
diff --git a/src/test/compile-fail/blind-item-block-middle.rs b/src/test/compile-fail/blind-item-block-middle.rs
index f57727b773d..0db7eaf0ca7 100644
--- a/src/test/compile-fail/blind-item-block-middle.rs
+++ b/src/test/compile-fail/blind-item-block-middle.rs
@@ -12,6 +12,6 @@ mod foo { pub struct bar; }
 
 fn main() {
     let bar = 5;
-    //~^ ERROR let bindings cannot shadow structs
+    //~^ ERROR let bindings cannot shadow unit structs
     use foo::bar;
 }
diff --git a/src/test/compile-fail/empty-struct-braces-pat-1.rs b/src/test/compile-fail/empty-struct-braces-pat-1.rs
index 74546152ca9..e527170e9f9 100644
--- a/src/test/compile-fail/empty-struct-braces-pat-1.rs
+++ b/src/test/compile-fail/empty-struct-braces-pat-1.rs
@@ -32,13 +32,13 @@ fn main() {
     }
     match e3 {
         E::Empty3 => ()
-        //~^ ERROR `E::Empty3` does not name a unit variant, unit struct or a constant
+        //~^ ERROR expected unit struct/variant or constant, found struct variant `E::Empty3`
     }
     match xe1 {
         XEmpty1 => () // Not an error, `XEmpty1` is interpreted as a new binding
     }
     match xe3 {
         XE::XEmpty3 => ()
-        //~^ ERROR `XE::XEmpty3` does not name a unit variant, unit struct or a constant
+        //~^ ERROR expected unit struct/variant or constant, found struct variant `XE::XEmpty3`
     }
 }
diff --git a/src/test/compile-fail/empty-struct-braces-pat-2.rs b/src/test/compile-fail/empty-struct-braces-pat-2.rs
index 52481517ce7..58e3ca6b3ac 100644
--- a/src/test/compile-fail/empty-struct-braces-pat-2.rs
+++ b/src/test/compile-fail/empty-struct-braces-pat-2.rs
@@ -24,15 +24,15 @@ fn main() {
     let xe1 = XEmpty1 {};
 
     match e1 {
-        Empty1() => () //~ ERROR unresolved variant or struct `Empty1`
+        Empty1() => () //~ ERROR unresolved tuple struct/variant `Empty1`
     }
     match xe1 {
-        XEmpty1() => () //~ ERROR unresolved variant or struct `XEmpty1`
+        XEmpty1() => () //~ ERROR unresolved tuple struct/variant `XEmpty1`
     }
     match e1 {
-        Empty1(..) => () //~ ERROR unresolved variant or struct `Empty1`
+        Empty1(..) => () //~ ERROR unresolved tuple struct/variant `Empty1`
     }
     match xe1 {
-        XEmpty1(..) => () //~ ERROR unresolved variant or struct `XEmpty1`
+        XEmpty1(..) => () //~ ERROR unresolved tuple struct/variant `XEmpty1`
     }
 }
diff --git a/src/test/compile-fail/empty-struct-braces-pat-3.rs b/src/test/compile-fail/empty-struct-braces-pat-3.rs
index cb859fe7501..1960eca9f80 100644
--- a/src/test/compile-fail/empty-struct-braces-pat-3.rs
+++ b/src/test/compile-fail/empty-struct-braces-pat-3.rs
@@ -26,15 +26,19 @@ fn main() {
     let xe3 = XE::XEmpty3 {};
 
     match e3 {
-        E::Empty3() => () //~ ERROR `E::Empty3` does not name a tuple variant or a tuple struct
+        E::Empty3() => ()
+        //~^ ERROR expected tuple struct/variant, found struct variant `E::Empty3`
     }
     match xe3 {
-        XE::XEmpty3() => () //~ ERROR `XE::XEmpty3` does not name a tuple variant or a tuple struct
+        XE::XEmpty3() => ()
+        //~^ ERROR expected tuple struct/variant, found struct variant `XE::XEmpty3`
     }
     match e3 {
-        E::Empty3(..) => () //~ ERROR `E::Empty3` does not name a tuple variant or a tuple struct
+        E::Empty3(..) => ()
+        //~^ ERROR expected tuple struct/variant, found struct variant `E::Empty3`
     }
     match xe3 {
-        XE::XEmpty3(..) => () //~ ERROR `XE::XEmpty3` does not name a tuple variant or a tuple
+        XE::XEmpty3(..) => ()
+        //~^ ERROR expected tuple struct/variant, found struct variant `XE::XEmpty3
     }
 }
diff --git a/src/test/compile-fail/empty-struct-tuple-pat.rs b/src/test/compile-fail/empty-struct-tuple-pat.rs
index be90e3b26c7..f15c126a126 100644
--- a/src/test/compile-fail/empty-struct-tuple-pat.rs
+++ b/src/test/compile-fail/empty-struct-tuple-pat.rs
@@ -31,17 +31,19 @@ fn main() {
     let xe5 = XE::XEmpty5();
 
     match e2 {
-        Empty2 => () //~ ERROR `Empty2` does not name a unit variant, unit struct or a constant
+        Empty2 => () //~ ERROR match bindings cannot shadow tuple structs
     }
     match xe6 {
-        XEmpty6 => () //~ ERROR `XEmpty6` does not name a unit variant, unit struct or a constant
+        XEmpty6 => () //~ ERROR match bindings cannot shadow tuple structs
     }
 
     match e4 {
-        E::Empty4 => () //~ ERROR `E::Empty4` does not name a unit variant, unit struct or a
+        E::Empty4 => ()
+        //~^ ERROR expected unit struct/variant or constant, found tuple variant `E::Empty4`
     }
     match xe5 {
-        XE::XEmpty5 => (), //~ ERROR `XE::XEmpty5` does not name a unit variant, unit struct or a
+        XE::XEmpty5 => (),
+        //~^ ERROR expected unit struct/variant or constant, found tuple variant `XE::XEmpty5`
         _ => {},
     }
 }
diff --git a/src/test/compile-fail/empty-struct-unit-pat-1.rs b/src/test/compile-fail/empty-struct-unit-pat-1.rs
index aec4ad4cad4..273cb48b2d2 100644
--- a/src/test/compile-fail/empty-struct-unit-pat-1.rs
+++ b/src/test/compile-fail/empty-struct-unit-pat-1.rs
@@ -31,21 +31,22 @@ fn main() {
     let xe4 = XE::XEmpty4;
 
     match e2 {
-        Empty2(..) => () //~ ERROR `Empty2` does not name a tuple variant or a tuple struct
+        Empty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2`
             //~^ WARNING hard error
     }
     match xe2 {
-        XEmpty2(..) => () //~ ERROR `XEmpty2` does not name a tuple variant or a tuple struct
+        XEmpty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2`
             //~^ WARNING hard error
     }
 
     match e4 {
-        E::Empty4(..) => () //~ ERROR `E::Empty4` does not name a tuple variant or a tuple struct
+        E::Empty4(..) => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4`
             //~^ WARNING hard error
     }
     match xe4 {
-        XE::XEmpty4(..) => (), //~ ERROR `XE::XEmpty4` does not name a tuple variant or a tuple
-            //~^ WARNING hard error
+        XE::XEmpty4(..) => (),
+            //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4`
+            //~| WARNING hard error
         _ => {},
     }
 }
diff --git a/src/test/compile-fail/empty-struct-unit-pat-2.rs b/src/test/compile-fail/empty-struct-unit-pat-2.rs
index 6375a7f2338..993f10e0806 100644
--- a/src/test/compile-fail/empty-struct-unit-pat-2.rs
+++ b/src/test/compile-fail/empty-struct-unit-pat-2.rs
@@ -23,7 +23,6 @@ enum E {
     Empty4
 }
 
-// remove attribute after warning cycle and promoting warnings to errors
 fn main() {
     let e2 = Empty2;
     let e4 = E::Empty4;
@@ -31,17 +30,21 @@ fn main() {
     let xe4 = XE::XEmpty4;
 
     match e2 {
-        Empty2() => () //~ ERROR `Empty2` does not name a tuple variant or a tuple struct
+        Empty2() => ()
+        //~^ ERROR expected tuple struct/variant, found unit struct `Empty2`
     }
     match xe2 {
-        XEmpty2() => () //~ ERROR `XEmpty2` does not name a tuple variant or a tuple struct
+        XEmpty2() => ()
+        //~^ ERROR expected tuple struct/variant, found unit struct `XEmpty2`
     }
 
     match e4 {
-        E::Empty4() => () //~ ERROR `E::Empty4` does not name a tuple variant or a tuple struct
+        E::Empty4() => ()
+        //~^ ERROR expected tuple struct/variant, found unit variant `E::Empty4`
     }
     match xe4 {
-        XE::XEmpty4() => (), //~ ERROR `XE::XEmpty4` does not name a tuple variant or a tuple
+        XE::XEmpty4() => (),
+        //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4`
         _ => {},
     }
 }
diff --git a/src/test/compile-fail/enum-in-scope.rs b/src/test/compile-fail/enum-in-scope.rs
index e89b08a8a06..bc1bd03f2d6 100644
--- a/src/test/compile-fail/enum-in-scope.rs
+++ b/src/test/compile-fail/enum-in-scope.rs
@@ -11,5 +11,5 @@
 struct hello(isize);
 
 fn main() {
-    let hello = 0; //~ERROR let bindings cannot shadow structs
+    let hello = 0; //~ERROR let bindings cannot shadow tuple structs
 }
diff --git a/src/test/compile-fail/enums-pats-not-idents.rs b/src/test/compile-fail/enums-pats-not-idents.rs
index c847366a707..03bdbe4e54b 100644
--- a/src/test/compile-fail/enums-pats-not-idents.rs
+++ b/src/test/compile-fail/enums-pats-not-idents.rs
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 fn main() {
-    let a(1) = 13; //~ ERROR unresolved variant or struct `a`
+    let a(1) = 13; //~ ERROR unresolved tuple struct/variant `a`
 }
diff --git a/src/test/compile-fail/issue-10200.rs b/src/test/compile-fail/issue-10200.rs
index 9eec8487a50..8c58ef6261e 100644
--- a/src/test/compile-fail/issue-10200.rs
+++ b/src/test/compile-fail/issue-10200.rs
@@ -13,7 +13,7 @@ fn foo(_: usize) -> Foo { Foo(false) }
 
 fn main() {
     match Foo(true) {
-        foo(x) //~ ERROR expected variant or struct, found function `foo`
+        foo(x) //~ ERROR expected tuple struct/variant, found function `foo`
         => ()
     }
 }
diff --git a/src/test/compile-fail/issue-12863.rs b/src/test/compile-fail/issue-12863.rs
index 7912410f69e..d3432410c54 100644
--- a/src/test/compile-fail/issue-12863.rs
+++ b/src/test/compile-fail/issue-12863.rs
@@ -12,6 +12,6 @@ mod foo { pub fn bar() {} }
 
 fn main() {
     match () {
-        foo::bar => {} //~ ERROR expected variant, struct or constant, found function `bar`
+        foo::bar => {} //~ ERROR expected unit struct/variant or constant, found function `foo::bar`
     }
 }
diff --git a/src/test/compile-fail/issue-17933.rs b/src/test/compile-fail/issue-17933.rs
index 2313a3fe9c6..049a0665c54 100644
--- a/src/test/compile-fail/issue-17933.rs
+++ b/src/test/compile-fail/issue-17933.rs
@@ -13,7 +13,7 @@ pub static X: usize = 1;
 fn main() {
     match 1 {
         self::X => { },
-        //~^ ERROR expected variant, struct or constant, found static `X`
+        //~^ ERROR expected unit struct/variant or constant, found static `self::X`
         _       => { },
     }
 }
diff --git a/src/test/compile-fail/issue-19086.rs b/src/test/compile-fail/issue-19086.rs
index 56452449d4e..ba571ce17fd 100644
--- a/src/test/compile-fail/issue-19086.rs
+++ b/src/test/compile-fail/issue-19086.rs
@@ -18,6 +18,6 @@ fn main() {
     let f = FooB { x: 3, y: 4 };
     match f {
         FooB(a, b) => println!("{} {}", a, b),
-//~^ ERROR `FooB` does not name a tuple variant or a tuple struct
+        //~^ ERROR expected tuple struct/variant, found struct variant `FooB`
     }
 }
diff --git a/src/test/compile-fail/issue-27033.rs b/src/test/compile-fail/issue-27033.rs
index 2a015adb498..b8552aaee90 100644
--- a/src/test/compile-fail/issue-27033.rs
+++ b/src/test/compile-fail/issue-27033.rs
@@ -10,7 +10,7 @@
 
 fn main() {
     match Some(1) {
-        None @ _ => {} //~ ERROR match bindings cannot shadow variants
+        None @ _ => {} //~ ERROR match bindings cannot shadow unit variants
     };
     const C: u8 = 1;
     match 1 {
diff --git a/src/test/compile-fail/issue-27815.rs b/src/test/compile-fail/issue-27815.rs
index 7a329bac61b..33930d1db14 100644
--- a/src/test/compile-fail/issue-27815.rs
+++ b/src/test/compile-fail/issue-27815.rs
@@ -14,7 +14,9 @@ fn main() {
     let u = A { x: 1 }; //~ ERROR `A` does not name a struct or a struct variant
     let v = u32 { x: 1 }; //~ ERROR `u32` does not name a struct or a struct variant
     match () {
-        A { x: 1 } => {} //~ ERROR expected variant, struct or type alias, found module `A`
-        u32 { x: 1 } => {} //~ ERROR expected variant, struct or type alias, found builtin type `u32
+        A { x: 1 } => {}
+        //~^ ERROR expected variant, struct or type alias, found module `A`
+        u32 { x: 1 } => {}
+        //~^ ERROR expected variant, struct or type alias, found builtin type `u32`
     }
 }
diff --git a/src/test/compile-fail/issue-28992-empty.rs b/src/test/compile-fail/issue-28992-empty.rs
index e492d48fdaf..d47fdda0203 100644
--- a/src/test/compile-fail/issue-28992-empty.rs
+++ b/src/test/compile-fail/issue-28992-empty.rs
@@ -21,6 +21,7 @@ impl S {
 }
 
 fn main() {
-    if let C1(..) = 0 {} //~ ERROR expected variant or struct, found constant `C1`
-    if let S::C2(..) = 0 {} //~ ERROR `S::C2` does not name a tuple variant or a tuple struct
+    if let C1(..) = 0 {} //~ ERROR expected tuple struct/variant, found constant `C1`
+    if let S::C2(..) = 0 {}
+    //~^ ERROR expected tuple struct/variant, found associated constant `S::C2`
 }
diff --git a/src/test/compile-fail/issue-32004.rs b/src/test/compile-fail/issue-32004.rs
index 576451f7292..7e1f4c28d21 100644
--- a/src/test/compile-fail/issue-32004.rs
+++ b/src/test/compile-fail/issue-32004.rs
@@ -18,12 +18,12 @@ struct S;
 fn main() {
     match Foo::Baz {
         Foo::Bar => {}
-        //~^ ERROR `Foo::Bar` does not name a unit variant, unit struct or a constant
+        //~^ ERROR expected unit struct/variant or constant, found tuple variant `Foo::Bar`
         _ => {}
     }
 
     match S {
         S(()) => {}
-        //~^ ERROR `S` does not name a tuple variant or a tuple struct
+        //~^ ERROR expected tuple struct/variant, found unit struct `S`
     }
 }
diff --git a/src/test/compile-fail/issue-32086.rs b/src/test/compile-fail/issue-32086.rs
index 926f58198df..dd236b76a67 100644
--- a/src/test/compile-fail/issue-32086.rs
+++ b/src/test/compile-fail/issue-32086.rs
@@ -12,6 +12,6 @@ struct S(u8);
 const C: S = S(10);
 
 fn main() {
-    let C(a) = S(11); //~ ERROR expected variant or struct, found constant `C`
-    let C(..) = S(11); //~ ERROR expected variant or struct, found constant `C`
+    let C(a) = S(11); //~ ERROR expected tuple struct/variant, found constant `C`
+    let C(..) = S(11); //~ ERROR expected tuple struct/variant, found constant `C`
 }
diff --git a/src/test/compile-fail/issue-5927.rs b/src/test/compile-fail/issue-5927.rs
index 3a8ff12429a..7668a2117a2 100644
--- a/src/test/compile-fail/issue-5927.rs
+++ b/src/test/compile-fail/issue-5927.rs
@@ -11,7 +11,7 @@
 
 fn main() {
     let z = match 3 {
-        x(1) => x(1) //~ ERROR unresolved variant or struct `x`
+        x(1) => x(1) //~ ERROR unresolved tuple struct/variant `x`
         //~^ ERROR unresolved name `x`
     };
     assert!(z == 3);
diff --git a/src/test/compile-fail/match-pattern-field-mismatch-2.rs b/src/test/compile-fail/match-pattern-field-mismatch-2.rs
index a4ba93ea173..aed9130d60e 100644
--- a/src/test/compile-fail/match-pattern-field-mismatch-2.rs
+++ b/src/test/compile-fail/match-pattern-field-mismatch-2.rs
@@ -20,7 +20,7 @@ fn main() {
           color::rgb(_, _, _) => { }
           color::cmyk(_, _, _, _) => { }
           color::no_color(_) => { }
-          //~^ ERROR `color::no_color` does not name a tuple variant or a tuple struct
+          //~^ ERROR expected tuple struct/variant, found unit variant `color::no_color`
         }
     }
 }
diff --git a/src/test/compile-fail/match-pattern-field-mismatch.rs b/src/test/compile-fail/match-pattern-field-mismatch.rs
index 8426ecdaf99..ddd5d633170 100644
--- a/src/test/compile-fail/match-pattern-field-mismatch.rs
+++ b/src/test/compile-fail/match-pattern-field-mismatch.rs
@@ -18,7 +18,7 @@ fn main() {
     fn foo(c: color) {
         match c {
           color::rgb(_, _) => { }
-          //~^ ERROR this pattern has 2 fields, but the corresponding variant has 3 fields
+          //~^ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields
           color::cmyk(_, _, _, _) => { }
           color::no_color => { }
         }
diff --git a/src/test/compile-fail/method-path-in-pattern.rs b/src/test/compile-fail/method-path-in-pattern.rs
index ef011c89c62..aaa89b22829 100644
--- a/src/test/compile-fail/method-path-in-pattern.rs
+++ b/src/test/compile-fail/method-path-in-pattern.rs
@@ -22,13 +22,13 @@ impl MyTrait for Foo {}
 
 fn main() {
     match 0u32 {
-        Foo::bar => {} //~ ERROR `Foo::bar` does not name a unit variant, unit struct or a constant
+        Foo::bar => {} //~ ERROR expected unit struct/variant or constant, found method `Foo::bar`
     }
     match 0u32 {
-        <Foo>::bar => {} //~ ERROR `bar` does not name a unit variant, unit struct or a constant
+        <Foo>::bar => {} //~ ERROR expected unit struct/variant or constant, found method `bar`
     }
     match 0u32 {
         <Foo>::trait_bar => {}
-        //~^ ERROR `trait_bar` does not name a unit variant, unit struct or a constant
+        //~^ ERROR expected unit struct/variant or constant, found method `trait_bar`
     }
 }
diff --git a/src/test/compile-fail/method-resolvable-path-in-pattern.rs b/src/test/compile-fail/method-resolvable-path-in-pattern.rs
index 3ae792f9c0f..4d8959466b9 100644
--- a/src/test/compile-fail/method-resolvable-path-in-pattern.rs
+++ b/src/test/compile-fail/method-resolvable-path-in-pattern.rs
@@ -19,6 +19,6 @@ impl MyTrait for Foo {}
 fn main() {
     match 0u32 {
         <Foo as MyTrait>::trait_bar => {}
-        //~^ ERROR expected variant, struct or constant, found method `trait_bar`
+        //~^ ERROR expected unit struct/variant or constant, found method `MyTrait::trait_bar`
     }
 }
diff --git a/src/test/compile-fail/name-clash-nullary.rs b/src/test/compile-fail/name-clash-nullary.rs
index 2e2d53c4d40..4c76c4b8b02 100644
--- a/src/test/compile-fail/name-clash-nullary.rs
+++ b/src/test/compile-fail/name-clash-nullary.rs
@@ -11,7 +11,7 @@
 use std::option::*;
 
 fn main() {
-  let None: isize = 42; //~ ERROR let bindings cannot shadow variants
+  let None: isize = 42; //~ ERROR let bindings cannot shadow unit variants
   log(debug, None);
   //~^ ERROR unresolved name `debug`
   //~| ERROR unresolved name `log`
diff --git a/src/test/compile-fail/pat-shadow-in-nested-binding.rs b/src/test/compile-fail/pat-shadow-in-nested-binding.rs
index f1683e51c64..3dbe08f1908 100644
--- a/src/test/compile-fail/pat-shadow-in-nested-binding.rs
+++ b/src/test/compile-fail/pat-shadow-in-nested-binding.rs
@@ -11,5 +11,5 @@
 struct foo(usize);
 
 fn main() {
-    let (foo, _) = (2, 3); //~ ERROR let bindings cannot shadow structs
+    let (foo, _) = (2, 3); //~ ERROR let bindings cannot shadow tuple structs
 }
diff --git a/src/test/compile-fail/pat-tuple-overfield.rs b/src/test/compile-fail/pat-tuple-overfield.rs
index 034ef4a72e2..069c1dc0aea 100644
--- a/src/test/compile-fail/pat-tuple-overfield.rs
+++ b/src/test/compile-fail/pat-tuple-overfield.rs
@@ -20,9 +20,9 @@ fn main() {
     }
     match S(1, 2, 3) {
         S(1, 2, 3, 4) => {}
-        //~^ ERROR this pattern has 4 fields, but the corresponding struct has 3 fields
+        //~^ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields
         S(1, 2, .., 3, 4) => {}
-        //~^ ERROR this pattern has 4 fields, but the corresponding struct has 3 fields
+        //~^ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields
         _ => {}
     }
 }
diff --git a/src/test/compile-fail/pattern-error-continue.rs b/src/test/compile-fail/pattern-error-continue.rs
index 507012e8c5c..e63b84594aa 100644
--- a/src/test/compile-fail/pattern-error-continue.rs
+++ b/src/test/compile-fail/pattern-error-continue.rs
@@ -25,7 +25,7 @@ fn f(_c: char) {}
 fn main() {
     match A::B(1, 2) {
         A::B(_, _, _) => (), //~ ERROR this pattern has 3 fields, but
-        A::D(_) => (),       //~ ERROR `A::D` does not name a tuple variant or a tuple struct
+        A::D(_) => (),       //~ ERROR expected tuple struct/variant, found unit variant `A::D`
         _ => ()
     }
     match 'c' {
diff --git a/src/test/compile-fail/qualified-path-params.rs b/src/test/compile-fail/qualified-path-params.rs
index 9034e24a6fe..82b0536a64a 100644
--- a/src/test/compile-fail/qualified-path-params.rs
+++ b/src/test/compile-fail/qualified-path-params.rs
@@ -28,7 +28,7 @@ impl S {
 fn main() {
     match 10 {
         <S as Tr>::A::f::<u8> => {}
-        //~^ ERROR `Tr::A::f<u8>` does not name a unit variant, unit struct or a constant
+        //~^ ERROR expected unit struct/variant or constant, found method `Tr::A::f<u8>`
         0 ... <S as Tr>::A::f::<u8> => {} //~ ERROR only char and numeric types are allowed in range
     }
 }
diff --git a/src/test/compile-fail/xcrate-private-by-default.rs b/src/test/compile-fail/xcrate-private-by-default.rs
index 3bd4c780625..7dd4d970945 100644
--- a/src/test/compile-fail/xcrate-private-by-default.rs
+++ b/src/test/compile-fail/xcrate-private-by-default.rs
@@ -39,7 +39,7 @@ fn main() {
     foo::<static_priv_by_default::m>();
     //~^ ERROR: enum `m` is private
     foo::<static_priv_by_default::n>();
-    //~^ ERROR: type `n` is private
+    //~^ ERROR: type alias `n` is private
 
     // public items in a private mod should be inaccessible
     static_priv_by_default::foo::a;