Rollup merge of #48198 - csmoe:inform_type_annotations, r=estebank
inform user where to give a type annotation should resolve #47777 previous pull request https://github.com/rust-lang/rust/pull/47982 was closed because of a mistaken rebase. r? @estebank
This commit is contained in:
commit
ad83b47802
@ -337,7 +337,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
|
||||
scope_expr_id,
|
||||
span,
|
||||
&format!("the type of this value must be known in this context"));
|
||||
&format!("type annotations needed"));
|
||||
}
|
||||
} else {
|
||||
let t = self.structurally_resolved_type(span, final_ty);
|
||||
|
@ -5052,9 +5052,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
ty
|
||||
} else {
|
||||
if !self.is_tainted_by_errors() {
|
||||
type_error_struct!(self.tcx.sess, sp, ty, E0619,
|
||||
"the type of this value must be known in this context")
|
||||
.emit();
|
||||
self.need_type_info((**self).body_id, sp, ty);
|
||||
}
|
||||
self.demand_suptype(sp, self.tcx.types.err, ty);
|
||||
self.tcx.types.err
|
||||
|
@ -4368,12 +4368,13 @@ i_am_a_function();
|
||||
"##,
|
||||
|
||||
E0619: r##"
|
||||
#### Note: this error code is no longer emitted by the compiler.
|
||||
The type-checker needed to know the type of an expression, but that type had not
|
||||
yet been inferred.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0619
|
||||
```compile_fail
|
||||
let mut x = vec![];
|
||||
match x.pop() {
|
||||
Some(v) => {
|
||||
|
@ -18,6 +18,6 @@ fn main() {
|
||||
let x = 0;
|
||||
let y = &x as *const _;
|
||||
let _ = y.is_null();
|
||||
//~^ error: the type of this value must be known in this context [tyvar_behind_raw_pointer]
|
||||
//~^ error: type annotations needed [tyvar_behind_raw_pointer]
|
||||
//~^^ warning: this was previously accepted
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
fn main() {
|
||||
return
|
||||
{ return () }
|
||||
//~^ ERROR the type of this value must be known in this context
|
||||
//~^ ERROR type annotations needed [E0282]
|
||||
()
|
||||
;
|
||||
}
|
||||
|
@ -10,5 +10,5 @@
|
||||
|
||||
fn main() {
|
||||
let x = panic!();
|
||||
x.clone(); //~ ERROR the type of this value must be known in this context
|
||||
x.clone(); //~ ERROR type annotations needed
|
||||
}
|
||||
|
@ -43,6 +43,6 @@ fn main() {
|
||||
fn another_fn_to_avoid_suppression() {
|
||||
match Default::default()
|
||||
{
|
||||
[] => {} //~ ERROR the type of this value
|
||||
[] => {} //~ ERROR type annotations needed
|
||||
};
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ fn main() {
|
||||
let x;
|
||||
|
||||
match x {
|
||||
(..) => {} //~ ERROR the type of this value must be known in this context
|
||||
(..) => {} //~ ERROR type annotations needed
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ fn a() {
|
||||
match closure0.take() {
|
||||
Some(c) => {
|
||||
return c();
|
||||
//~^ ERROR the type of this value must be known in this context
|
||||
//~^ ERROR type annotations needed
|
||||
}
|
||||
None => { }
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
// 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
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
error[E0619]: the type of this value must be known in this context
|
||||
--> $DIR/E0619.rs:15:9
|
||||
|
|
||||
15 | (..) => {} //~ ERROR E0619
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,4 +1,4 @@
|
||||
warning: the type of this value must be known in this context
|
||||
warning: type annotations needed
|
||||
--> $DIR/inference-variable-behind-raw-pointer.rs:18:13
|
||||
|
|
||||
18 | if data.is_null() {}
|
||||
|
@ -15,11 +15,11 @@
|
||||
fn shines_a_beacon_through_the_darkness() {
|
||||
let x: Option<_> = None;
|
||||
x.unwrap().method_that_could_exist_on_some_type();
|
||||
//~^ ERROR 17:5: 17:15: the type of this value must be known in this context
|
||||
//~^ ERROR 17:5: 17:15: type annotations needed
|
||||
}
|
||||
|
||||
fn courier_to_des_moines_and_points_west(data: &[u32]) -> String {
|
||||
data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context
|
||||
data.iter() //~ ERROR 22:5: 23:20: type annotations needed
|
||||
.sum::<_>()
|
||||
.to_string()
|
||||
}
|
||||
|
@ -1,15 +1,17 @@
|
||||
error[E0619]: the type of this value must be known in this context
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-42234-unknown-receiver-type.rs:17:5
|
||||
|
|
||||
16 | let x: Option<_> = None;
|
||||
| - consider giving `x` a type
|
||||
17 | x.unwrap().method_that_could_exist_on_some_type();
|
||||
| ^^^^^^^^^^
|
||||
| ^^^^^^^^^^ cannot infer type for `T`
|
||||
|
||||
error[E0619]: the type of this value must be known in this context
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-42234-unknown-receiver-type.rs:22:5
|
||||
|
|
||||
22 | / data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context
|
||||
22 | / data.iter() //~ ERROR 22:5: 23:20: type annotations needed
|
||||
23 | | .sum::<_>()
|
||||
| |___________________^
|
||||
| |___________________^ cannot infer type for `_`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user