mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Add E0619
This commit is contained in:
parent
0816b94f02
commit
09f42fb9cc
@ -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;
|
||||
|
@ -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! {
|
||||
|
18
src/test/compile-fail/E0619.rs
Normal file
18
src/test/compile-fail/E0619.rs
Normal 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
|
||||
_ => {}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user