about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-20 12:17:23 +0100
committerGitHub <noreply@github.com>2019-12-20 12:17:23 +0100
commit403bb097fce6f1d1fbb3b7b12d024f20ce845900 (patch)
treeee4124a8c052d1b64648b5bfd47b302ef8d2d3af /src/test
parentb779cbbe6806caccb73f21ac6aeba99316ca8900 (diff)
parent8a4632dec69082301d3fe67e48d422bc9fb665be (diff)
downloadrust-403bb097fce6f1d1fbb3b7b12d024f20ce845900.tar.gz
rust-403bb097fce6f1d1fbb3b7b12d024f20ce845900.zip
Rollup merge of #67285 - ohadravid:indicate-origin-of-where-type-parameter, r=estebank
Indicate origin of where type parameter for uninferred types

Based on #65951 (which is not merge yet), fixes #67277.

This PR improves a little the diagnostic for code like:

```
 async fn foo() {
     bar().await;
}

 async fn bar<T>() -> () {}
```

by showing:
```
error[E0698]: type inside `async fn` body must be known in this context
 --> unresolved_type_param.rs:9:5
  |
9 |     bar().await;
  |     ^^^ cannot infer type for type parameter `T` declared on the function `bar`
  |
...
```
(The
```
declared on the function `bar`
```
part is new)

A small side note: `Vec` and `slice` seem to resist this change, because querying `item_name()` panics, and `get_opt_name()` returns `None`.

r? @estebank
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/async-await/unresolved_type_param.stderr2
-rw-r--r--src/test/ui/const-generics/fn-const-param-infer.stderr2
-rw-r--r--src/test/ui/consts/issue-64662.stderr4
-rw-r--r--src/test/ui/error-codes/E0401.stderr2
-rw-r--r--src/test/ui/issues/issue-12028.stderr2
-rw-r--r--src/test/ui/issues/issue-16966.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-5062.stderr2
-rw-r--r--src/test/ui/issues/issue-6458-2.stderr2
-rw-r--r--src/test/ui/issues/issue-6458-3.stderr2
-rw-r--r--src/test/ui/issues/issue-6458.stderr2
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter.stderr2
-rw-r--r--src/test/ui/span/type-annotations-needed-expr.stderr2
-rw-r--r--src/test/ui/traits/traits-multidispatch-convert-ambig-dest.stderr2
-rw-r--r--src/test/ui/type-inference/or_else-multiple-type-params.stderr2
-rw-r--r--src/test/ui/type-inference/sort_by_key.stderr2
-rw-r--r--src/test/ui/type-inference/unbounded-associated-type.stderr2
-rw-r--r--src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr2
-rw-r--r--src/test/ui/type-inference/unbounded-type-param-in-fn.stderr2
-rw-r--r--src/test/ui/type/type-annotation-needed.stderr2
-rw-r--r--src/test/ui/unconstrained-none.stderr2
-rw-r--r--src/test/ui/unconstrained-ref.stderr2
23 files changed, 24 insertions, 24 deletions
diff --git a/src/test/ui/async-await/unresolved_type_param.stderr b/src/test/ui/async-await/unresolved_type_param.stderr
index b9b4f5133b9..3ffdb8ce6b9 100644
--- a/src/test/ui/async-await/unresolved_type_param.stderr
+++ b/src/test/ui/async-await/unresolved_type_param.stderr
@@ -2,7 +2,7 @@ error[E0698]: type inside `async fn` body must be known in this context
   --> $DIR/unresolved_type_param.rs:9:5
    |
 LL |     bar().await;
-   |     ^^^ cannot infer type for type parameter `T`
+   |     ^^^ cannot infer type for type parameter `T` declared on the function `bar`
    |
 note: the type is part of the `async fn` body because of this `await`
   --> $DIR/unresolved_type_param.rs:9:5
diff --git a/src/test/ui/const-generics/fn-const-param-infer.stderr b/src/test/ui/const-generics/fn-const-param-infer.stderr
index 9ccad7bcdd7..44eab8baa40 100644
--- a/src/test/ui/const-generics/fn-const-param-infer.stderr
+++ b/src/test/ui/const-generics/fn-const-param-infer.stderr
@@ -30,7 +30,7 @@ error[E0282]: type annotations needed
   --> $DIR/fn-const-param-infer.rs:22:23
    |
 LL |     let _ = Checked::<generic>;
-   |                       ^^^^^^^ cannot infer type for type parameter `T`
+   |                       ^^^^^^^ cannot infer type for type parameter `T` declared on the function `generic`
 
 error[E0308]: mismatched types
   --> $DIR/fn-const-param-infer.rs:25:40
diff --git a/src/test/ui/consts/issue-64662.stderr b/src/test/ui/consts/issue-64662.stderr
index b3c673ec027..dd281e911da 100644
--- a/src/test/ui/consts/issue-64662.stderr
+++ b/src/test/ui/consts/issue-64662.stderr
@@ -2,13 +2,13 @@ error[E0282]: type annotations needed
   --> $DIR/issue-64662.rs:2:9
    |
 LL |     A = foo(),
-   |         ^^^ cannot infer type for type parameter `T`
+   |         ^^^ cannot infer type for type parameter `T` declared on the function `foo`
 
 error[E0282]: type annotations needed
   --> $DIR/issue-64662.rs:3:9
    |
 LL |     B = foo(),
-   |         ^^^ cannot infer type for type parameter `T`
+   |         ^^^ cannot infer type for type parameter `T` declared on the function `foo`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/error-codes/E0401.stderr b/src/test/ui/error-codes/E0401.stderr
index 0adf982d71c..8b1d4e6c07c 100644
--- a/src/test/ui/error-codes/E0401.stderr
+++ b/src/test/ui/error-codes/E0401.stderr
@@ -36,7 +36,7 @@ error[E0282]: type annotations needed
   --> $DIR/E0401.rs:11:5
    |
 LL |     bfnr(x);
-   |     ^^^^ cannot infer type for type parameter `U`
+   |     ^^^^ cannot infer type for type parameter `U` declared on the function `bfnr`
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/issues/issue-12028.stderr b/src/test/ui/issues/issue-12028.stderr
index 5f2dd729c73..fe7e8f89f7f 100644
--- a/src/test/ui/issues/issue-12028.stderr
+++ b/src/test/ui/issues/issue-12028.stderr
@@ -2,7 +2,7 @@ error[E0284]: type annotations needed
   --> $DIR/issue-12028.rs:27:14
    |
 LL |         self.input_stream(&mut stream);
-   |              ^^^^^^^^^^^^ cannot infer type for type parameter `H`
+   |              ^^^^^^^^^^^^ cannot infer type for type parameter `H` declared on the trait `StreamHash`
    |
    = note: cannot resolve `<_ as StreamHasher>::S == <H as StreamHasher>::S`
 
diff --git a/src/test/ui/issues/issue-16966.stderr b/src/test/ui/issues/issue-16966.stderr
index 0d565af79b5..49a12cc2009 100644
--- a/src/test/ui/issues/issue-16966.stderr
+++ b/src/test/ui/issues/issue-16966.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/issue-16966.rs:2:5
    |
 LL |     panic!(std::default::Default::default());
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `M`
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `M` declared on the function `begin_panic`
    |
    = 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/issues/issue-17551.stderr b/src/test/ui/issues/issue-17551.stderr
index 5468268e7de..48405a292f3 100644
--- a/src/test/ui/issues/issue-17551.stderr
+++ b/src/test/ui/issues/issue-17551.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `B<T>`
   --> $DIR/issue-17551.rs:6:15
    |
 LL |     let foo = B(marker::PhantomData);
-   |         ---   ^ cannot infer type for type parameter `T`
+   |         ---   ^ cannot infer type for type parameter `T` declared on the struct `B`
    |         |
    |         consider giving `foo` the explicit type `B<T>`, where the type parameter `T` is specified
 
diff --git a/src/test/ui/issues/issue-25368.stderr b/src/test/ui/issues/issue-25368.stderr
index de020d4b56b..a09de86a708 100644
--- a/src/test/ui/issues/issue-25368.stderr
+++ b/src/test/ui/issues/issue-25368.stderr
@@ -5,7 +5,7 @@ LL |     let (tx, rx) = channel();
    |         -------- 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 type parameter `T`
+   |                 ^^^ cannot infer type for type parameter `T` declared on the struct `Foo`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-5062.stderr b/src/test/ui/issues/issue-5062.stderr
index a20118d6911..9fa15dc9679 100644
--- a/src/test/ui/issues/issue-5062.stderr
+++ b/src/test/ui/issues/issue-5062.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/issue-5062.rs:1:29
    |
 LL | fn main() { format!("{:?}", None); }
-   |                             ^^^^ cannot infer type for type parameter `T`
+   |                             ^^^^ cannot infer type for type parameter `T` declared on the enum `Option`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-6458-2.stderr b/src/test/ui/issues/issue-6458-2.stderr
index d538a69045f..da16f95dc3d 100644
--- a/src/test/ui/issues/issue-6458-2.stderr
+++ b/src/test/ui/issues/issue-6458-2.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/issue-6458-2.rs:3:21
    |
 LL |     format!("{:?}", None);
-   |                     ^^^^ cannot infer type for type parameter `T`
+   |                     ^^^^ cannot infer type for type parameter `T` declared on the enum `Option`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-6458-3.stderr b/src/test/ui/issues/issue-6458-3.stderr
index 6b3f469ee37..a71c159db0b 100644
--- a/src/test/ui/issues/issue-6458-3.stderr
+++ b/src/test/ui/issues/issue-6458-3.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/issue-6458-3.rs:4:5
    |
 LL |     mem::transmute(0);
-   |     ^^^^^^^^^^^^^^ cannot infer type for type parameter `U`
+   |     ^^^^^^^^^^^^^^ cannot infer type for type parameter `U` declared on the function `transmute`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-6458.stderr b/src/test/ui/issues/issue-6458.stderr
index de315659b6d..f1a982616a4 100644
--- a/src/test/ui/issues/issue-6458.stderr
+++ b/src/test/ui/issues/issue-6458.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/issue-6458.rs:9:4
    |
 LL |    foo(TypeWithState(marker::PhantomData));
-   |    ^^^ cannot infer type for type parameter `State`
+   |    ^^^ cannot infer type for type parameter `State` declared on the function `foo`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter.stderr b/src/test/ui/missing/missing-items/missing-type-parameter.stderr
index be97f2373c3..1219badc5b3 100644
--- a/src/test/ui/missing/missing-items/missing-type-parameter.stderr
+++ b/src/test/ui/missing/missing-items/missing-type-parameter.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/missing-type-parameter.rs:4:5
    |
 LL |     foo();
-   |     ^^^ cannot infer type for type parameter `X`
+   |     ^^^ cannot infer type for type parameter `X` declared on the function `foo`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/span/type-annotations-needed-expr.stderr b/src/test/ui/span/type-annotations-needed-expr.stderr
index 8366285edcd..2b92f9b93bf 100644
--- a/src/test/ui/span/type-annotations-needed-expr.stderr
+++ b/src/test/ui/span/type-annotations-needed-expr.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     let _ = (vec![1,2,3]).into_iter().sum() as f64;
    |                                       ^^^
    |                                       |
-   |                                       cannot infer type for type parameter `S`
+   |                                       cannot infer type for type parameter `S` declared on the method `sum`
    |                                       help: consider specifying the type argument in the method call: `sum::<S>`
    |
    = note: type must be known at this point
diff --git a/src/test/ui/traits/traits-multidispatch-convert-ambig-dest.stderr b/src/test/ui/traits/traits-multidispatch-convert-ambig-dest.stderr
index 7bcda234c4b..338c8cbf2e4 100644
--- a/src/test/ui/traits/traits-multidispatch-convert-ambig-dest.stderr
+++ b/src/test/ui/traits/traits-multidispatch-convert-ambig-dest.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/traits-multidispatch-convert-ambig-dest.rs:26:5
    |
 LL |     test(22, std::default::Default::default());
-   |     ^^^^ cannot infer type for type parameter `U`
+   |     ^^^^ cannot infer type for type parameter `U` declared on the function `test`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-inference/or_else-multiple-type-params.stderr b/src/test/ui/type-inference/or_else-multiple-type-params.stderr
index 141cc25ffe2..b9258b20f5a 100644
--- a/src/test/ui/type-inference/or_else-multiple-type-params.stderr
+++ b/src/test/ui/type-inference/or_else-multiple-type-params.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |         .or_else(|err| {
    |          ^^^^^^^
    |          |
-   |          cannot infer type for type parameter `F`
+   |          cannot infer type for type parameter `F` declared on the method `or_else`
    |          help: consider specifying the type arguments in the method call: `or_else::<F, O>`
 
 error: aborting due to previous error
diff --git a/src/test/ui/type-inference/sort_by_key.stderr b/src/test/ui/type-inference/sort_by_key.stderr
index 1d386bd1f42..e74c0dfa5e2 100644
--- a/src/test/ui/type-inference/sort_by_key.stderr
+++ b/src/test/ui/type-inference/sort_by_key.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     lst.sort_by_key(|&(v, _)| v.iter().sum());
    |         ^^^^^^^^^^^                    --- help: consider specifying the type argument in the method call: `sum::<S>`
    |         |
-   |         cannot infer type for type parameter `K`
+   |         cannot infer type for type parameter `K` declared on the method `sort_by_key`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-inference/unbounded-associated-type.stderr b/src/test/ui/type-inference/unbounded-associated-type.stderr
index 726dd4b4758..19e2bd4513d 100644
--- a/src/test/ui/type-inference/unbounded-associated-type.stderr
+++ b/src/test/ui/type-inference/unbounded-associated-type.stderr
@@ -8,7 +8,7 @@ LL |     S(std::marker::PhantomData).foo();
    |     ^--------------------------------
    |     |
    |     this method call resolves to `<Self as T>::A`
-   |     cannot infer type for type parameter `X`
+   |     cannot infer type for type parameter `X` declared on the struct `S`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr b/src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr
index 52039d0e934..d60ca4a4932 100644
--- a/src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr
+++ b/src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/unbounded-type-param-in-fn-with-assoc-type.rs:8:5
    |
 LL |     foo();
-   |     ^^^ cannot infer type for type parameter `T`
+   |     ^^^ cannot infer type for type parameter `T` declared on the function `foo`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-inference/unbounded-type-param-in-fn.stderr b/src/test/ui/type-inference/unbounded-type-param-in-fn.stderr
index 8d317df6ce9..45d879d8d56 100644
--- a/src/test/ui/type-inference/unbounded-type-param-in-fn.stderr
+++ b/src/test/ui/type-inference/unbounded-type-param-in-fn.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/unbounded-type-param-in-fn.rs:6:5
    |
 LL |     foo();
-   |     ^^^ cannot infer type for type parameter `T`
+   |     ^^^ cannot infer type for type parameter `T` declared on the function `foo`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type/type-annotation-needed.stderr b/src/test/ui/type/type-annotation-needed.stderr
index 94425440d33..c6a811e8363 100644
--- a/src/test/ui/type/type-annotation-needed.stderr
+++ b/src/test/ui/type/type-annotation-needed.stderr
@@ -7,7 +7,7 @@ LL | fn foo<T: Into<String>>(x: i32) {}
 LL |     foo(42);
    |     ^^^
    |     |
-   |     cannot infer type for type parameter `T`
+   |     cannot infer type for type parameter `T` declared on the function `foo`
    |     help: consider specifying the type argument in the function call: `foo::<T>`
    |
    = note: cannot resolve `_: std::convert::Into<std::string::String>`
diff --git a/src/test/ui/unconstrained-none.stderr b/src/test/ui/unconstrained-none.stderr
index 6c4fde94a61..fbd71bd091d 100644
--- a/src/test/ui/unconstrained-none.stderr
+++ b/src/test/ui/unconstrained-none.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/unconstrained-none.rs:4:5
    |
 LL |     None;
-   |     ^^^^ cannot infer type for type parameter `T`
+   |     ^^^^ cannot infer type for type parameter `T` declared on the enum `Option`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/unconstrained-ref.stderr b/src/test/ui/unconstrained-ref.stderr
index d6985a61daf..eb8ebb5165d 100644
--- a/src/test/ui/unconstrained-ref.stderr
+++ b/src/test/ui/unconstrained-ref.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/unconstrained-ref.rs:6:5
    |
 LL |     S { o: &None };
-   |     ^ cannot infer type for type parameter `T`
+   |     ^ cannot infer type for type parameter `T` declared on the struct `S`
 
 error: aborting due to previous error