Skip to content

Commit 9616b33

Browse files
committed
review comment: tweak wording
1 parent ebbe725 commit 9616b33

15 files changed

+47
-43
lines changed

src/librustc/infer/error_reporting/need_type_info.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,24 +142,28 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
142142
// trying to infer. In the following example, `ty_msg` contains
143143
// " in `std::result::Result<i32, E>`":
144144
// ```
145-
// error[E0282]: type annotations needed in `std::result::Result<i32, E>`
145+
// error[E0282]: type annotations needed for `std::result::Result<i32, E>`
146146
// --> file.rs:L:CC
147147
// |
148148
// L | let b = Ok(4);
149149
// | - ^^ cannot infer type for `E` in `std::result::Result<i32, E>`
150150
// | |
151-
// | consider giving `b` the type `std::result::Result<i32, E>` with the type
152-
// | parameter `E` specified
151+
// | consider giving `b` the explicit type `std::result::Result<i32, E>`, where
152+
// | the type parameter `E` is specified
153153
// ```
154154
let (ty_msg, suffix) = match &local_visitor.found_ty {
155155
Some(ty) if &ty.to_string() != "_" && ty.to_string() != name => {
156156
let ty = ty_to_string(ty);
157-
(format!(" in `{}`", ty),
158-
format!( "the type `{}` with the type parameter `{}` specified", ty, name))
157+
(format!(" for `{}`", ty),
158+
format!(
159+
"the explicit type `{}`, where the type parameter `{}` is specified",
160+
ty,
161+
name,
162+
))
159163
}
160164
_ => (String::new(), "a type".to_owned()),
161165
};
162-
let mut labels = vec![(span, InferCtxt::missing_type_msg(&name, &ty_msg))];
166+
let mut labels = vec![(span, InferCtxt::missing_type_msg(&name))];
163167

164168
if let Some(pattern) = local_visitor.found_arg_pattern {
165169
err_span = pattern.span;
@@ -229,15 +233,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
229233
span,
230234
E0698,
231235
"type inside generator must be known in this context");
232-
err.span_label(span, InferCtxt::missing_type_msg(&name, ""));
236+
err.span_label(span, InferCtxt::missing_type_msg(&name));
233237
err
234238
}
235239

236-
fn missing_type_msg(type_name: &str, postfix: &str) -> String {
240+
fn missing_type_msg(type_name: &str) -> String {
237241
if type_name == "_" {
238242
"cannot infer type".to_owned()
239243
} else {
240-
format!("cannot infer type for `{}`{}", type_name, postfix)
244+
format!("cannot infer type for `{}`", type_name)
241245
}
242246
}
243247
}

src/test/ui/issues/issue-12187-1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0282]: type annotations needed in `&T`
1+
error[E0282]: type annotations needed for `&T`
22
--> $DIR/issue-12187-1.rs:6:10
33
|
44
LL | let &v = new();
55
| -^
66
| ||
77
| |cannot infer type
8-
| consider giving this pattern the type `&T` with the type parameter `_` specified
8+
| consider giving this pattern the explicit type `&T`, where the type parameter `_` is specified
99

1010
error: aborting due to previous error
1111

src/test/ui/issues/issue-12187-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0282]: type annotations needed in `&T`
1+
error[E0282]: type annotations needed for `&T`
22
--> $DIR/issue-12187-2.rs:6:10
33
|
44
LL | let &v = new();
55
| -^
66
| ||
77
| |cannot infer type
8-
| consider giving this pattern the type `&T` with the type parameter `_` specified
8+
| consider giving this pattern the explicit type `&T`, where the type parameter `_` is specified
99

1010
error: aborting due to previous error
1111

src/test/ui/issues/issue-17551.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0282]: type annotations needed in `B<T>`
1+
error[E0282]: type annotations needed for `B<T>`
22
--> $DIR/issue-17551.rs:6:15
33
|
44
LL | let foo = B(marker::PhantomData);
5-
| --- ^ cannot infer type for `T` in `B<T>`
5+
| --- ^ cannot infer type for `T`
66
| |
7-
| consider giving `foo` the type `B<T>` with the type parameter `T` specified
7+
| consider giving `foo` the explicit type `B<T>`, where the type parameter `T` is specified
88

99
error: aborting due to previous error
1010

src/test/ui/issues/issue-20261.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0282]: type annotations needed in `&(_,)`
1+
error[E0282]: type annotations needed for `&(_,)`
22
--> $DIR/issue-20261.rs:4:11
33
|
44
LL | for (ref i,) in [].iter() {

src/test/ui/issues/issue-23046.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0282]: type annotations needed in `Expr<'_, VAR>`
1+
error[E0282]: type annotations needed for `Expr<'_, VAR>`
22
--> $DIR/issue-23046.rs:17:15
33
|
44
LL | let ex = |x| {
5-
| ^ consider giving this closure parameter the type `Expr<'_, VAR>` with the type parameter `VAR` specified
5+
| ^ consider giving this closure parameter the explicit type `Expr<'_, VAR>`, where the type parameter `VAR` is specified
66

77
error: aborting due to previous error
88

src/test/ui/issues/issue-25368.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0282]: type annotations needed in `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)`
1+
error[E0282]: type annotations needed for `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)`
22
--> $DIR/issue-25368.rs:11:17
33
|
44
LL | let (tx, rx) = channel();
5-
| -------- consider giving this pattern the type `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)` with the type parameter `T` specified
5+
| -------- consider giving this pattern the explicit type `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)`, where the type parameter `T` is specified
66
...
77
LL | tx.send(Foo{ foo: PhantomData });
8-
| ^^^ cannot infer type for `T` in `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)`
8+
| ^^^ cannot infer type for `T`
99

1010
error: aborting due to previous error
1111

src/test/ui/issues/issue-7813.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0282]: type annotations needed in `&[_; 0]`
1+
error[E0282]: type annotations needed for `&[_; 0]`
22
--> $DIR/issue-7813.rs:2:13
33
|
44
LL | let v = &[];
55
| - ^^^ cannot infer type
66
| |
7-
| consider giving `v` the type `&[_; 0]` with the type parameter `_` specified
7+
| consider giving `v` the explicit type `&[_; 0]`, where the type parameter `_` is specified
88

99
error: aborting due to previous error
1010

src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0282]: type annotations needed in `std::vec::Vec<T>`
1+
error[E0282]: type annotations needed for `std::vec::Vec<T>`
22
--> $DIR/method-ambig-one-trait-unknown-int-type.rs:24:17
33
|
44
LL | let mut x = Vec::new();
5-
| ----- ^^^^^^^^ cannot infer type for `T` in `std::vec::Vec<T>`
5+
| ----- ^^^^^^^^ cannot infer type for `T`
66
| |
7-
| consider giving `x` the type `std::vec::Vec<T>` with the type parameter `T` specified
7+
| consider giving `x` the explicit type `std::vec::Vec<T>`, where the type parameter `T` is specified
88

99
error[E0308]: mismatched types
1010
--> $DIR/method-ambig-one-trait-unknown-int-type.rs:33:20

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0282]: type annotations needed in `std::option::Option<_>`
1+
error[E0282]: type annotations needed for `std::option::Option<_>`
22
--> $DIR/issue-42234-unknown-receiver-type.rs:7:5
33
|
44
LL | let x: Option<_> = None;
5-
| - consider giving `x` the type `std::option::Option<_>` with the type parameter `T` specified
5+
| - consider giving `x` the explicit type `std::option::Option<_>`, where the type parameter `T` is specified
66
LL | x.unwrap().method_that_could_exist_on_some_type();
7-
| ^^^^^^^^^^ cannot infer type for `T` in `std::option::Option<_>`
7+
| ^^^^^^^^^^ cannot infer type for `T`
88
|
99
= note: type must be known at this point
1010

src/test/ui/type/type-check/cannot_infer_local_or_array.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0282]: type annotations needed in `[_; 0]`
1+
error[E0282]: type annotations needed for `[_; 0]`
22
--> $DIR/cannot_infer_local_or_array.rs:2:13
33
|
44
LL | let x = [];
55
| - ^^ cannot infer type
66
| |
7-
| consider giving `x` the type `[_; 0]` with the type parameter `_` specified
7+
| consider giving `x` the explicit type `[_; 0]`, where the type parameter `_` is specified
88

99
error: aborting due to previous error
1010

src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0282]: type annotations needed in `std::vec::Vec<T>`
1+
error[E0282]: type annotations needed for `std::vec::Vec<T>`
22
--> $DIR/cannot_infer_local_or_vec.rs:2:13
33
|
44
LL | let x = vec![];
5-
| - ^^^^^^ cannot infer type for `T` in `std::vec::Vec<T>`
5+
| - ^^^^^^ cannot infer type for `T`
66
| |
7-
| consider giving `x` the type `std::vec::Vec<T>` with the type parameter `T` specified
7+
| consider giving `x` the explicit type `std::vec::Vec<T>`, where the type parameter `T` is specified
88
|
99
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1010

src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0282]: type annotations needed in `(std::vec::Vec<T>,)`
1+
error[E0282]: type annotations needed for `(std::vec::Vec<T>,)`
22
--> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:18
33
|
44
LL | let (x, ) = (vec![], );
5-
| ----- ^^^^^^ cannot infer type for `T` in `(std::vec::Vec<T>,)`
5+
| ----- ^^^^^^ cannot infer type for `T`
66
| |
7-
| consider giving this pattern the type `(std::vec::Vec<T>,)` with the type parameter `T` specified
7+
| consider giving this pattern the explicit type `(std::vec::Vec<T>,)`, where the type parameter `T` is specified
88
|
99
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1010

src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0282]: type annotations needed in `std::option::Option<T>`
1+
error[E0282]: type annotations needed for `std::option::Option<T>`
22
--> $DIR/unboxed-closures-failed-recursive-fn-2.rs:16:32
33
|
44
LL | let mut closure0 = None;
5-
| ------------ consider giving `closure0` the type `std::option::Option<T>` with the type parameter `_` specified
5+
| ------------ consider giving `closure0` the explicit type `std::option::Option<T>`, where the type parameter `_` is specified
66
...
77
LL | return c();
88
| ^^^ cannot infer type

src/test/ui/vector-no-ann.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0282]: type annotations needed in `std::vec::Vec<T>`
1+
error[E0282]: type annotations needed for `std::vec::Vec<T>`
22
--> $DIR/vector-no-ann.rs:2:16
33
|
44
LL | let _foo = Vec::new();
5-
| ---- ^^^^^^^^ cannot infer type for `T` in `std::vec::Vec<T>`
5+
| ---- ^^^^^^^^ cannot infer type for `T`
66
| |
7-
| consider giving `_foo` the type `std::vec::Vec<T>` with the type parameter `T` specified
7+
| consider giving `_foo` the explicit type `std::vec::Vec<T>`, where the type parameter `T` is specified
88

99
error: aborting due to previous error
1010

0 commit comments

Comments
 (0)