about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/infer/error_reporting/need_type_info.rs32
-rw-r--r--src/test/ui/issues/issue-12187-1.stderr2
-rw-r--r--src/test/ui/issues/issue-12187-2.stderr2
-rw-r--r--src/test/ui/issues/issue-17551.stderr2
-rw-r--r--src/test/ui/issues/issue-25368.stderr2
-rw-r--r--src/test/ui/issues/issue-7813.stderr2
-rw-r--r--src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr2
-rw-r--r--src/test/ui/span/issue-42234-unknown-receiver-type.stderr2
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_array.stderr2
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr2
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr2
-rw-r--r--src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr2
-rw-r--r--src/test/ui/vector-no-ann.stderr2
13 files changed, 25 insertions, 31 deletions
diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs
index 85ff1cbc9e4..bfe2cbbd1cd 100644
--- a/src/librustc/infer/error_reporting/need_type_info.rs
+++ b/src/librustc/infer/error_reporting/need_type_info.rs
@@ -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)));
             }
         };
 
diff --git a/src/test/ui/issues/issue-12187-1.stderr b/src/test/ui/issues/issue-12187-1.stderr
index 5f07dbc6673..25340a2e242 100644
--- a/src/test/ui/issues/issue-12187-1.stderr
+++ b/src/test/ui/issues/issue-12187-1.stderr
@@ -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
 
diff --git a/src/test/ui/issues/issue-12187-2.stderr b/src/test/ui/issues/issue-12187-2.stderr
index 5b44278359c..e0f060b26e6 100644
--- a/src/test/ui/issues/issue-12187-2.stderr
+++ b/src/test/ui/issues/issue-12187-2.stderr
@@ -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
 
diff --git a/src/test/ui/issues/issue-17551.stderr b/src/test/ui/issues/issue-17551.stderr
index 95af1e41b58..11dd66129d2 100644
--- a/src/test/ui/issues/issue-17551.stderr
+++ b/src/test/ui/issues/issue-17551.stderr
@@ -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
 
diff --git a/src/test/ui/issues/issue-25368.stderr b/src/test/ui/issues/issue-25368.stderr
index a386fc94628..3f0beaee3b1 100644
--- a/src/test/ui/issues/issue-25368.stderr
+++ b/src/test/ui/issues/issue-25368.stderr
@@ -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>>)`
diff --git a/src/test/ui/issues/issue-7813.stderr b/src/test/ui/issues/issue-7813.stderr
index 7338032098b..65088079476 100644
--- a/src/test/ui/issues/issue-7813.stderr
+++ b/src/test/ui/issues/issue-7813.stderr
@@ -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
 
diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
index b9fa36041b1..842aa8a1f38 100644
--- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
+++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
@@ -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
diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
index 2ae942e48e6..5e052165321 100644
--- a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
+++ b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
@@ -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<_>`
    |
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr
index d3c726cf8e7..428ea6de6ed 100644
--- a/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr
@@ -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
 
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr
index a491d4516cc..8d0dc18ab90 100644
--- a/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr
@@ -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)
 
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr
index 1c5b750b9b4..5cd898f3fef 100644
--- a/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr
@@ -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)
 
diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr
index dda453870dc..4804983b861 100644
--- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr
+++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr
@@ -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
diff --git a/src/test/ui/vector-no-ann.stderr b/src/test/ui/vector-no-ann.stderr
index a6c805c0c26..3ece3063cd0 100644
--- a/src/test/ui/vector-no-ann.stderr
+++ b/src/test/ui/vector-no-ann.stderr
@@ -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