Add E0619

This commit is contained in:
Guillaume Gomez 2017-06-24 22:26:45 +02:00
parent 0816b94f02
commit 09f42fb9cc
3 changed files with 48 additions and 3 deletions

View File

@ -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;

View File

@ -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! {

View File

@ -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
_ => {}
}
}