Skip to content

Commit ad83b47

Browse files
Rollup merge of rust-lang#48198 - csmoe:inform_type_annotations, r=estebank
inform user where to give a type annotation should resolve rust-lang#47777 previous pull request rust-lang#47982 was closed because of a mistaken rebase. r? @estebank
2 parents f0343cb + 4370a58 commit ad83b47

14 files changed

+20
-46
lines changed

src/librustc_typeck/check/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
337337
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
338338
scope_expr_id,
339339
span,
340-
&format!("the type of this value must be known in this context"));
340+
&format!("type annotations needed"));
341341
}
342342
} else {
343343
let t = self.structurally_resolved_type(span, final_ty);

src/librustc_typeck/check/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -5052,9 +5052,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50525052
ty
50535053
} else {
50545054
if !self.is_tainted_by_errors() {
5055-
type_error_struct!(self.tcx.sess, sp, ty, E0619,
5056-
"the type of this value must be known in this context")
5057-
.emit();
5055+
self.need_type_info((**self).body_id, sp, ty);
50585056
}
50595057
self.demand_suptype(sp, self.tcx.types.err, ty);
50605058
self.tcx.types.err

src/librustc_typeck/diagnostics.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4368,12 +4368,13 @@ i_am_a_function();
43684368
"##,
43694369

43704370
E0619: r##"
4371+
#### Note: this error code is no longer emitted by the compiler.
43714372
The type-checker needed to know the type of an expression, but that type had not
43724373
yet been inferred.
43734374
43744375
Erroneous code example:
43754376
4376-
```compile_fail,E0619
4377+
```compile_fail
43774378
let mut x = vec![];
43784379
match x.pop() {
43794380
Some(v) => {

src/test/compile-fail/epoch-raw-pointer-method-2015.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ fn main() {
1818
let x = 0;
1919
let y = &x as *const _;
2020
let _ = y.is_null();
21-
//~^ error: the type of this value must be known in this context [tyvar_behind_raw_pointer]
21+
//~^ error: type annotations needed [tyvar_behind_raw_pointer]
2222
//~^^ warning: this was previously accepted
2323
}

src/test/compile-fail/issue-15965.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fn main() {
1212
return
1313
{ return () }
14-
//~^ ERROR the type of this value must be known in this context
14+
//~^ ERROR type annotations needed [E0282]
1515
()
1616
;
1717
}

src/test/compile-fail/issue-2151.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010

1111
fn main() {
1212
let x = panic!();
13-
x.clone(); //~ ERROR the type of this value must be known in this context
13+
x.clone(); //~ ERROR type annotations needed
1414
}

src/test/compile-fail/match-vec-mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ fn main() {
4343
fn another_fn_to_avoid_suppression() {
4444
match Default::default()
4545
{
46-
[] => {} //~ ERROR the type of this value
46+
[] => {} //~ ERROR type annotations needed
4747
};
4848
}

src/test/compile-fail/pat-tuple-bad-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
let x;
1313

1414
match x {
15-
(..) => {} //~ ERROR the type of this value must be known in this context
15+
(..) => {} //~ ERROR type annotations needed
1616
_ => {}
1717
}
1818

src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn a() {
2424
match closure0.take() {
2525
Some(c) => {
2626
return c();
27-
//~^ ERROR the type of this value must be known in this context
27+
//~^ ERROR type annotations needed
2828
}
2929
None => { }
3030
}

src/test/ui/error-codes/E0619.rs

-19
This file was deleted.

src/test/ui/error-codes/E0619.stderr

-8
This file was deleted.

src/test/ui/inference-variable-behind-raw-pointer.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: the type of this value must be known in this context
1+
warning: type annotations needed
22
--> $DIR/inference-variable-behind-raw-pointer.rs:18:13
33
|
44
18 | if data.is_null() {}

src/test/ui/span/issue-42234-unknown-receiver-type.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
fn shines_a_beacon_through_the_darkness() {
1616
let x: Option<_> = None;
1717
x.unwrap().method_that_could_exist_on_some_type();
18-
//~^ ERROR 17:5: 17:15: the type of this value must be known in this context
18+
//~^ ERROR 17:5: 17:15: type annotations needed
1919
}
2020

2121
fn courier_to_des_moines_and_points_west(data: &[u32]) -> String {
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
2323
.sum::<_>()
2424
.to_string()
2525
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
error[E0619]: the type of this value must be known in this context
1+
error[E0282]: type annotations needed
22
--> $DIR/issue-42234-unknown-receiver-type.rs:17:5
33
|
4+
16 | let x: Option<_> = None;
5+
| - consider giving `x` a type
46
17 | x.unwrap().method_that_could_exist_on_some_type();
5-
| ^^^^^^^^^^
7+
| ^^^^^^^^^^ cannot infer type for `T`
68

7-
error[E0619]: the type of this value must be known in this context
9+
error[E0282]: type annotations needed
810
--> $DIR/issue-42234-unknown-receiver-type.rs:22:5
911
|
10-
22 | / data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context
12+
22 | / data.iter() //~ ERROR 22:5: 23:20: type annotations needed
1113
23 | | .sum::<_>()
12-
| |___________________^
14+
| |___________________^ cannot infer type for `_`
1315

1416
error: aborting due to 2 previous errors
1517

0 commit comments

Comments
 (0)