Skip to content
Permalink
Browse files

Account for cases where we can find the type arg name, but the local …

…name is `_`
  • Loading branch information...
estebank committed Jun 1, 2019
1 parent 9616b33 commit e420f4410ba44b3e39f54c755f456f4f65406e25
@@ -152,6 +152,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// | the type parameter `E` is specified
// ```
let (ty_msg, suffix) = match &local_visitor.found_ty {
Some(ty) if &ty.to_string() != "_" && name == "_" => {
let ty = ty_to_string(ty);
(format!(" for `{}`", ty),
format!("the explicit type `{}`, with the type parameters specified", ty))
}
Some(ty) if &ty.to_string() != "_" && ty.to_string() != name => {
let ty = ty_to_string(ty);
(format!(" for `{}`", ty),
@@ -5,7 +5,7 @@ LL | let &v = new();
| -^
| ||
| |cannot infer type
| consider giving this pattern the explicit type `&T`, where the type parameter `_` is specified
| consider giving this pattern the explicit type `&T`, with the type parameters specified

error: aborting due to previous error

@@ -5,7 +5,7 @@ LL | let &v = new();
| -^
| ||
| |cannot infer type
| consider giving this pattern the explicit type `&T`, where the type parameter `_` is specified
| consider giving this pattern the explicit type `&T`, with the type parameters specified

error: aborting due to previous error

@@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `&[_; 0]`
LL | let v = &[];
| - ^^^ cannot infer type
| |
| consider giving `v` the explicit type `&[_; 0]`, where the type parameter `_` is specified
| consider giving `v` the explicit type `&[_; 0]`, with the type parameters specified

error: aborting due to previous error

@@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `[_; 0]`
LL | let x = [];
| - ^^ cannot infer type
| |
| consider giving `x` the explicit type `[_; 0]`, where the type parameter `_` is specified
| consider giving `x` the explicit type `[_; 0]`, with the type parameters specified

error: aborting due to previous error

@@ -2,7 +2,7 @@ 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 explicit type `std::option::Option<T>`, where the type parameter `_` is specified
| ------------ consider giving `closure0` the explicit type `std::option::Option<T>`, with the type parameters specified
...
LL | return c();
| ^^^ cannot infer type

0 comments on commit e420f44

Please sign in to comment.
You can’t perform that action at this time.