Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inform user where to give a type annotation #48198

Merged
merged 4 commits into from
Feb 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/epoch-raw-pointer-method-2015.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-15965.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
()
;
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-2151.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/match-vec-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/pat-tuple-bad-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
_ => {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => { }
}
Expand Down
19 changes: 0 additions & 19 deletions src/test/ui/error-codes/E0619.rs

This file was deleted.

8 changes: 0 additions & 8 deletions src/test/ui/error-codes/E0619.stderr

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/ui/inference-variable-behind-raw-pointer.stderr
Original file line number Diff line number Diff line change
@@ -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() {}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/span/issue-42234-unknown-receiver-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
12 changes: 7 additions & 5 deletions src/test/ui/span/issue-42234-unknown-receiver-type.stderr
Original file line number Diff line number Diff line change
@@ -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