review comment: tweak wording
This commit is contained in:
parent
ebbe725dd0
commit
9616b333b2
|
@ -142,24 +142,28 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
// trying to infer. In the following example, `ty_msg` contains
|
||||
// " in `std::result::Result<i32, E>`":
|
||||
// ```
|
||||
// error[E0282]: type annotations needed in `std::result::Result<i32, E>`
|
||||
// error[E0282]: type annotations needed for `std::result::Result<i32, E>`
|
||||
// --> file.rs:L:CC
|
||||
// |
|
||||
// L | let b = Ok(4);
|
||||
// | - ^^ cannot infer type for `E` in `std::result::Result<i32, E>`
|
||||
// | |
|
||||
// | consider giving `b` the type `std::result::Result<i32, E>` with the type
|
||||
// | parameter `E` specified
|
||||
// | consider giving `b` the explicit type `std::result::Result<i32, E>`, where
|
||||
// | the type parameter `E` is specified
|
||||
// ```
|
||||
let (ty_msg, suffix) = match &local_visitor.found_ty {
|
||||
Some(ty) if &ty.to_string() != "_" && ty.to_string() != name => {
|
||||
let ty = ty_to_string(ty);
|
||||
(format!(" in `{}`", ty),
|
||||
format!( "the type `{}` with the type parameter `{}` specified", ty, name))
|
||||
(format!(" for `{}`", ty),
|
||||
format!(
|
||||
"the explicit type `{}`, where the type parameter `{}` is specified",
|
||||
ty,
|
||||
name,
|
||||
))
|
||||
}
|
||||
_ => (String::new(), "a type".to_owned()),
|
||||
};
|
||||
let mut labels = vec![(span, InferCtxt::missing_type_msg(&name, &ty_msg))];
|
||||
let mut labels = vec![(span, InferCtxt::missing_type_msg(&name))];
|
||||
|
||||
if let Some(pattern) = local_visitor.found_arg_pattern {
|
||||
err_span = pattern.span;
|
||||
|
@ -229,15 +233,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
span,
|
||||
E0698,
|
||||
"type inside generator must be known in this context");
|
||||
err.span_label(span, InferCtxt::missing_type_msg(&name, ""));
|
||||
err.span_label(span, InferCtxt::missing_type_msg(&name));
|
||||
err
|
||||
}
|
||||
|
||||
fn missing_type_msg(type_name: &str, postfix: &str) -> String {
|
||||
fn missing_type_msg(type_name: &str) -> String {
|
||||
if type_name == "_" {
|
||||
"cannot infer type".to_owned()
|
||||
} else {
|
||||
format!("cannot infer type for `{}`{}", type_name, postfix)
|
||||
format!("cannot infer type for `{}`", type_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0282]: type annotations needed in `&T`
|
||||
error[E0282]: type annotations needed for `&T`
|
||||
--> $DIR/issue-12187-1.rs:6:10
|
||||
|
|
||||
LL | let &v = new();
|
||||
| -^
|
||||
| ||
|
||||
| |cannot infer type
|
||||
| consider giving this pattern the type `&T` with the type parameter `_` specified
|
||||
| consider giving this pattern the explicit type `&T`, where the type parameter `_` is specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0282]: type annotations needed in `&T`
|
||||
error[E0282]: type annotations needed for `&T`
|
||||
--> $DIR/issue-12187-2.rs:6:10
|
||||
|
|
||||
LL | let &v = new();
|
||||
| -^
|
||||
| ||
|
||||
| |cannot infer type
|
||||
| consider giving this pattern the type `&T` with the type parameter `_` specified
|
||||
| consider giving this pattern the explicit type `&T`, where the type parameter `_` is specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0282]: type annotations needed in `B<T>`
|
||||
error[E0282]: type annotations needed for `B<T>`
|
||||
--> $DIR/issue-17551.rs:6:15
|
||||
|
|
||||
LL | let foo = B(marker::PhantomData);
|
||||
| --- ^ cannot infer type for `T` in `B<T>`
|
||||
| --- ^ cannot infer type for `T`
|
||||
| |
|
||||
| consider giving `foo` the type `B<T>` with the type parameter `T` specified
|
||||
| consider giving `foo` the explicit type `B<T>`, where the type parameter `T` is specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0282]: type annotations needed in `&(_,)`
|
||||
error[E0282]: type annotations needed for `&(_,)`
|
||||
--> $DIR/issue-20261.rs:4:11
|
||||
|
|
||||
LL | for (ref i,) in [].iter() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0282]: type annotations needed in `Expr<'_, VAR>`
|
||||
error[E0282]: type annotations needed for `Expr<'_, VAR>`
|
||||
--> $DIR/issue-23046.rs:17:15
|
||||
|
|
||||
LL | let ex = |x| {
|
||||
| ^ consider giving this closure parameter the type `Expr<'_, VAR>` with the type parameter `VAR` specified
|
||||
| ^ consider giving this closure parameter the explicit type `Expr<'_, VAR>`, where the type parameter `VAR` is specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0282]: type annotations needed in `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)`
|
||||
error[E0282]: type annotations needed for `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)`
|
||||
--> $DIR/issue-25368.rs:11:17
|
||||
|
|
||||
LL | let (tx, rx) = channel();
|
||||
| -------- consider giving this pattern the type `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)` with the type parameter `T` specified
|
||||
| -------- 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
|
||||
...
|
||||
LL | tx.send(Foo{ foo: PhantomData });
|
||||
| ^^^ cannot infer type for `T` in `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)`
|
||||
| ^^^ cannot infer type for `T`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0282]: type annotations needed in `&[_; 0]`
|
||||
error[E0282]: type annotations needed for `&[_; 0]`
|
||||
--> $DIR/issue-7813.rs:2:13
|
||||
|
|
||||
LL | let v = &[];
|
||||
| - ^^^ cannot infer type
|
||||
| |
|
||||
| consider giving `v` the type `&[_; 0]` with the type parameter `_` specified
|
||||
| consider giving `v` the explicit type `&[_; 0]`, where the type parameter `_` is specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0282]: type annotations needed in `std::vec::Vec<T>`
|
||||
error[E0282]: type annotations needed for `std::vec::Vec<T>`
|
||||
--> $DIR/method-ambig-one-trait-unknown-int-type.rs:24:17
|
||||
|
|
||||
LL | let mut x = Vec::new();
|
||||
| ----- ^^^^^^^^ cannot infer type for `T` in `std::vec::Vec<T>`
|
||||
| ----- ^^^^^^^^ cannot infer type for `T`
|
||||
| |
|
||||
| consider giving `x` the type `std::vec::Vec<T>` with the type parameter `T` specified
|
||||
| consider giving `x` the explicit type `std::vec::Vec<T>`, where the type parameter `T` is specified
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/method-ambig-one-trait-unknown-int-type.rs:33:20
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0282]: type annotations needed in `std::option::Option<_>`
|
||||
error[E0282]: type annotations needed for `std::option::Option<_>`
|
||||
--> $DIR/issue-42234-unknown-receiver-type.rs:7:5
|
||||
|
|
||||
LL | let x: Option<_> = None;
|
||||
| - consider giving `x` the type `std::option::Option<_>` with the type parameter `T` specified
|
||||
| - consider giving `x` the explicit type `std::option::Option<_>`, where the type parameter `T` is specified
|
||||
LL | x.unwrap().method_that_could_exist_on_some_type();
|
||||
| ^^^^^^^^^^ cannot infer type for `T` in `std::option::Option<_>`
|
||||
| ^^^^^^^^^^ cannot infer type for `T`
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0282]: type annotations needed in `[_; 0]`
|
||||
error[E0282]: type annotations needed for `[_; 0]`
|
||||
--> $DIR/cannot_infer_local_or_array.rs:2:13
|
||||
|
|
||||
LL | let x = [];
|
||||
| - ^^ cannot infer type
|
||||
| |
|
||||
| consider giving `x` the type `[_; 0]` with the type parameter `_` specified
|
||||
| consider giving `x` the explicit type `[_; 0]`, where the type parameter `_` is specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0282]: type annotations needed in `std::vec::Vec<T>`
|
||||
error[E0282]: type annotations needed for `std::vec::Vec<T>`
|
||||
--> $DIR/cannot_infer_local_or_vec.rs:2:13
|
||||
|
|
||||
LL | let x = vec![];
|
||||
| - ^^^^^^ cannot infer type for `T` in `std::vec::Vec<T>`
|
||||
| - ^^^^^^ cannot infer type for `T`
|
||||
| |
|
||||
| consider giving `x` the type `std::vec::Vec<T>` with the type parameter `T` specified
|
||||
| consider giving `x` the explicit type `std::vec::Vec<T>`, where the type parameter `T` is specified
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0282]: type annotations needed in `(std::vec::Vec<T>,)`
|
||||
error[E0282]: type annotations needed for `(std::vec::Vec<T>,)`
|
||||
--> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:18
|
||||
|
|
||||
LL | let (x, ) = (vec![], );
|
||||
| ----- ^^^^^^ cannot infer type for `T` in `(std::vec::Vec<T>,)`
|
||||
| ----- ^^^^^^ cannot infer type for `T`
|
||||
| |
|
||||
| consider giving this pattern the type `(std::vec::Vec<T>,)` with the type parameter `T` specified
|
||||
| consider giving this pattern the explicit type `(std::vec::Vec<T>,)`, where the type parameter `T` is specified
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0282]: type annotations needed in `std::option::Option<T>`
|
||||
error[E0282]: type annotations needed for `std::option::Option<T>`
|
||||
--> $DIR/unboxed-closures-failed-recursive-fn-2.rs:16:32
|
||||
|
|
||||
LL | let mut closure0 = None;
|
||||
| ------------ consider giving `closure0` the type `std::option::Option<T>` with the type parameter `_` specified
|
||||
| ------------ consider giving `closure0` the explicit type `std::option::Option<T>`, where the type parameter `_` is specified
|
||||
...
|
||||
LL | return c();
|
||||
| ^^^ cannot infer type
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0282]: type annotations needed in `std::vec::Vec<T>`
|
||||
error[E0282]: type annotations needed for `std::vec::Vec<T>`
|
||||
--> $DIR/vector-no-ann.rs:2:16
|
||||
|
|
||||
LL | let _foo = Vec::new();
|
||||
| ---- ^^^^^^^^ cannot infer type for `T` in `std::vec::Vec<T>`
|
||||
| ---- ^^^^^^^^ cannot infer type for `T`
|
||||
| |
|
||||
| consider giving `_foo` the type `std::vec::Vec<T>` with the type parameter `T` specified
|
||||
| consider giving `_foo` the explicit type `std::vec::Vec<T>`, where the type parameter `T` is specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
Loading…
Reference in New Issue