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 or the MIT license +// , 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 + _ => {} + } +}