Tweak wording
This commit is contained in:
parent
74fb3bbee4
commit
ebbe725dd0
@ -148,13 +148,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
// L | let b = Ok(4);
|
||||
// | - ^^ cannot infer type for `E` in `std::result::Result<i32, E>`
|
||||
// | |
|
||||
// | consider giving `b` a type
|
||||
// | consider giving `b` the type `std::result::Result<i32, E>` with the type
|
||||
// | parameter `E` specified
|
||||
// ```
|
||||
let ty_msg = match &local_visitor.found_ty {
|
||||
let (ty_msg, suffix) = match &local_visitor.found_ty {
|
||||
Some(ty) if &ty.to_string() != "_" && ty.to_string() != name => {
|
||||
format!(" in `{}`", ty_to_string(ty))
|
||||
let ty = ty_to_string(ty);
|
||||
(format!(" in `{}`", ty),
|
||||
format!( "the type `{}` with the type parameter `{}` specified", ty, name))
|
||||
}
|
||||
_ => String::new(),
|
||||
_ => (String::new(), "a type".to_owned()),
|
||||
};
|
||||
let mut labels = vec![(span, InferCtxt::missing_type_msg(&name, &ty_msg))];
|
||||
|
||||
@ -177,25 +180,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
// with the type parameter `_` specified
|
||||
// ```
|
||||
labels.clear();
|
||||
labels.push((pattern.span, format!(
|
||||
"consider giving this closure parameter {}",
|
||||
match &local_visitor.found_ty {
|
||||
Some(ty) if &ty.to_string() != "_" && ty.to_string() != name => {
|
||||
format!(
|
||||
"the type `{}` with the type parameter `{}` specified",
|
||||
ty_to_string(ty),
|
||||
name,
|
||||
)
|
||||
}
|
||||
_ => "a type".to_owned(),
|
||||
},
|
||||
)));
|
||||
labels.push((
|
||||
pattern.span,
|
||||
format!("consider giving this closure parameter {}", suffix),
|
||||
));
|
||||
} else if let Some(pattern) = local_visitor.found_local_pattern {
|
||||
if let Some(simple_ident) = pattern.simple_ident() {
|
||||
match pattern.span.compiler_desugaring_kind() {
|
||||
None => labels.push((
|
||||
pattern.span,
|
||||
format!("consider giving `{}` a type", simple_ident),
|
||||
format!("consider giving `{}` {}", simple_ident, suffix),
|
||||
)),
|
||||
Some(CompilerDesugaringKind::ForLoop) => labels.push((
|
||||
pattern.span,
|
||||
@ -204,7 +198,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
_ => {}
|
||||
}
|
||||
} else {
|
||||
labels.push((pattern.span, "consider giving the pattern a type".to_owned()));
|
||||
labels.push((pattern.span, format!("consider giving this pattern {}", suffix)));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | let &v = new();
|
||||
| -^
|
||||
| ||
|
||||
| |cannot infer type
|
||||
| consider giving the pattern a type
|
||||
| consider giving this pattern the type `&T` with the type parameter `_` specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,7 +5,7 @@ LL | let &v = new();
|
||||
| -^
|
||||
| ||
|
||||
| |cannot infer type
|
||||
| consider giving the pattern a type
|
||||
| consider giving this pattern the type `&T` with the type parameter `_` specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed in `B<T>`
|
||||
LL | let foo = B(marker::PhantomData);
|
||||
| --- ^ cannot infer type for `T` in `B<T>`
|
||||
| |
|
||||
| consider giving `foo` a type
|
||||
| consider giving `foo` the type `B<T>` with the type parameter `T` specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed in `(std::sync::mpsc::Sender<Foo<T>>, std:
|
||||
--> $DIR/issue-25368.rs:11:17
|
||||
|
|
||||
LL | let (tx, rx) = channel();
|
||||
| -------- consider giving the pattern a type
|
||||
| -------- consider giving this pattern the type `(std::sync::mpsc::Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)` with the type parameter `T` 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>>)`
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed in `&[_; 0]`
|
||||
LL | let v = &[];
|
||||
| - ^^^ cannot infer type
|
||||
| |
|
||||
| consider giving `v` a type
|
||||
| consider giving `v` the type `&[_; 0]` with the type parameter `_` specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed in `std::vec::Vec<T>`
|
||||
LL | let mut x = Vec::new();
|
||||
| ----- ^^^^^^^^ cannot infer type for `T` in `std::vec::Vec<T>`
|
||||
| |
|
||||
| consider giving `x` a type
|
||||
| consider giving `x` the type `std::vec::Vec<T>` with the type parameter `T` specified
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/method-ambig-one-trait-unknown-int-type.rs:33:20
|
||||
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed in `std::option::Option<_>`
|
||||
--> $DIR/issue-42234-unknown-receiver-type.rs:7:5
|
||||
|
|
||||
LL | let x: Option<_> = None;
|
||||
| - consider giving `x` a type
|
||||
| - consider giving `x` the type `std::option::Option<_>` with the type parameter `T` specified
|
||||
LL | x.unwrap().method_that_could_exist_on_some_type();
|
||||
| ^^^^^^^^^^ cannot infer type for `T` in `std::option::Option<_>`
|
||||
|
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed in `[_; 0]`
|
||||
LL | let x = [];
|
||||
| - ^^ cannot infer type
|
||||
| |
|
||||
| consider giving `x` a type
|
||||
| consider giving `x` the type `[_; 0]` with the type parameter `_` specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed in `std::vec::Vec<T>`
|
||||
LL | let x = vec![];
|
||||
| - ^^^^^^ cannot infer type for `T` in `std::vec::Vec<T>`
|
||||
| |
|
||||
| consider giving `x` a type
|
||||
| consider giving `x` the type `std::vec::Vec<T>` with the type parameter `T` 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)
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed in `(std::vec::Vec<T>,)`
|
||||
LL | let (x, ) = (vec![], );
|
||||
| ----- ^^^^^^ cannot infer type for `T` in `(std::vec::Vec<T>,)`
|
||||
| |
|
||||
| consider giving the pattern a type
|
||||
| consider giving this pattern the type `(std::vec::Vec<T>,)` with the type parameter `T` 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)
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed in `std::option::Option<T>`
|
||||
--> $DIR/unboxed-closures-failed-recursive-fn-2.rs:16:32
|
||||
|
|
||||
LL | let mut closure0 = None;
|
||||
| ------------ consider giving `closure0` a type
|
||||
| ------------ consider giving `closure0` the type `std::option::Option<T>` with the type parameter `_` specified
|
||||
...
|
||||
LL | return c();
|
||||
| ^^^ cannot infer type
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed in `std::vec::Vec<T>`
|
||||
LL | let _foo = Vec::new();
|
||||
| ---- ^^^^^^^^ cannot infer type for `T` in `std::vec::Vec<T>`
|
||||
| |
|
||||
| consider giving `_foo` a type
|
||||
| consider giving `_foo` the type `std::vec::Vec<T>` with the type parameter `T` specified
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user