about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2017-06-24 22:26:45 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2017-06-29 09:48:17 +0200
commit09f42fb9ccb4dfd728e323cbe5d25ed04a8262ad (patch)
treece548f358c7718a1fd7dbfbfdeaaec93981e08dd /src
parent0816b94f02e1cd20031b764370ed74102963527d (diff)
downloadrust-09f42fb9ccb4dfd728e323cbe5d25ed04a8262ad.tar.gz
rust-09f42fb9ccb4dfd728e323cbe5d25ed04a8262ad.zip
Add E0619
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/check/mod.rs6
-rw-r--r--src/librustc_typeck/diagnostics.rs27
-rw-r--r--src/test/compile-fail/E0619.rs18
3 files changed, 48 insertions, 3 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 34cf1d7f96b..a8d0be2bd04 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -4716,9 +4716,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
             // If not, error.
             if alternative.is_ty_var() || alternative.references_error() {
                 if !self.is_tainted_by_errors() {
-                    self.type_error_message(sp, |_actual| {
-                        "the type of this value must be known in this context".to_string()
-                    }, ty);
+                    type_error_struct!(self.tcx.sess, sp, ty, E0619,
+                                       "the type of this value must be known in this context")
+                        .emit();
                 }
                 self.demand_suptype(sp, self.tcx.types.err, ty);
                 ty = self.tcx.types.err;
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index bf5adc8644d..09c3445672a 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -4665,6 +4665,33 @@ i_am_a_function();
 ```
 "##,
 
+E0619: r##"
+A not (yet) known type was used.
+
+Erroneous code example:
+
+```compile_fail,E0619
+let x;
+
+match x {
+    (..) => {} // error: the type of this value must be known in this context
+    _ => {}
+}
+```
+
+To fix this error, just specify the type of the variable. Example:
+
+```
+let x: i32 = 0; // Here, we say that `x` is an `i32` (and give it a value to
+                // avoid another compiler error).
+
+match x {
+    0 => {} // ok!
+    _ => {}
+}
+```
+"##,
+
 }
 
 register_diagnostics! {
diff --git a/src/test/compile-fail/E0619.rs b/src/test/compile-fail/E0619.rs
new file mode 100644
index 00000000000..8ef90d89931
--- /dev/null
+++ b/src/test/compile-fail/E0619.rs
@@ -0,0 +1,18 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let x;
+
+    match x {
+        (..) => {} //~ ERROR E0619
+        _ => {}
+    }
+}