Skip to content

Commit 09f42fb

Browse files
Add E0619
1 parent 0816b94 commit 09f42fb

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,9 +4716,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47164716
// If not, error.
47174717
if alternative.is_ty_var() || alternative.references_error() {
47184718
if !self.is_tainted_by_errors() {
4719-
self.type_error_message(sp, |_actual| {
4720-
"the type of this value must be known in this context".to_string()
4721-
}, ty);
4719+
type_error_struct!(self.tcx.sess, sp, ty, E0619,
4720+
"the type of this value must be known in this context")
4721+
.emit();
47224722
}
47234723
self.demand_suptype(sp, self.tcx.types.err, ty);
47244724
ty = self.tcx.types.err;

src/librustc_typeck/diagnostics.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4665,6 +4665,33 @@ i_am_a_function();
46654665
```
46664666
"##,
46674667

4668+
E0619: r##"
4669+
A not (yet) known type was used.
4670+
4671+
Erroneous code example:
4672+
4673+
```compile_fail,E0619
4674+
let x;
4675+
4676+
match x {
4677+
(..) => {} // error: the type of this value must be known in this context
4678+
_ => {}
4679+
}
4680+
```
4681+
4682+
To fix this error, just specify the type of the variable. Example:
4683+
4684+
```
4685+
let x: i32 = 0; // Here, we say that `x` is an `i32` (and give it a value to
4686+
// avoid another compiler error).
4687+
4688+
match x {
4689+
0 => {} // ok!
4690+
_ => {}
4691+
}
4692+
```
4693+
"##,
4694+
46684695
}
46694696

46704697
register_diagnostics! {

src/test/compile-fail/E0619.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let x;
13+
14+
match x {
15+
(..) => {} //~ ERROR E0619
16+
_ => {}
17+
}
18+
}

0 commit comments

Comments
 (0)