about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2022-05-20 13:49:41 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2022-05-20 23:04:44 +0900
commit3d0f9fb544cc73ea4016696e43868b71bf3c8226 (patch)
tree22652854fcd39d055fdf260b8a3e52d36ae0d2d8 /src
parent910979a6d4a8e1945933cc989e6b22a675fc1d42 (diff)
downloadrust-3d0f9fb544cc73ea4016696e43868b71bf3c8226.tar.gz
rust-3d0f9fb544cc73ea4016696e43868b71bf3c8226.zip
report ambiguous type parameters when their parents are impl or fn
fix ci error

emit err for `impl_item`
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/const-generics/issues/issue-83249.stderr6
-rw-r--r--src/test/ui/consts/issue-64662.stderr12
-rw-r--r--src/test/ui/error-codes/E0401.stderr6
-rw-r--r--src/test/ui/inference/erase-type-params-in-label.stderr10
-rw-r--r--src/test/ui/inference/issue-86162-1.stderr5
-rw-r--r--src/test/ui/inference/issue-86162-2.stderr5
-rw-r--r--src/test/ui/issues/issue-6458.stderr6
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter.stderr6
-rw-r--r--src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr6
-rw-r--r--src/test/ui/traits/multidispatch-convert-ambig-dest.stderr11
-rw-r--r--src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr6
-rw-r--r--src/test/ui/type-inference/unbounded-type-param-in-fn.stderr6
-rw-r--r--src/test/ui/type/type-annotation-needed.stderr5
13 files changed, 90 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/issues/issue-83249.stderr b/src/test/ui/const-generics/issues/issue-83249.stderr
index 402b3aa2d61..3f44a54e80a 100644
--- a/src/test/ui/const-generics/issues/issue-83249.stderr
+++ b/src/test/ui/const-generics/issues/issue-83249.stderr
@@ -5,6 +5,12 @@ LL |     let _ = foo([0; 1]);
    |         -   ^^^ cannot infer type for type parameter `T` declared on the function `foo`
    |         |
    |         consider giving this pattern a type
+   |
+help: type parameter declared here
+  --> $DIR/issue-83249.rs:12:8
+   |
+LL | fn foo<T: Foo>(_: [u8; T::N]) -> T {
+   |        ^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/consts/issue-64662.stderr b/src/test/ui/consts/issue-64662.stderr
index dd281e911da..caa582d87f5 100644
--- a/src/test/ui/consts/issue-64662.stderr
+++ b/src/test/ui/consts/issue-64662.stderr
@@ -3,12 +3,24 @@ error[E0282]: type annotations needed
    |
 LL |     A = foo(),
    |         ^^^ cannot infer type for type parameter `T` declared on the function `foo`
+   |
+help: type parameter declared here
+  --> $DIR/issue-64662.rs:6:14
+   |
+LL | const fn foo<T>() -> isize {
+   |              ^
 
 error[E0282]: type annotations needed
   --> $DIR/issue-64662.rs:3:9
    |
 LL |     B = foo(),
    |         ^^^ cannot infer type for type parameter `T` declared on the function `foo`
+   |
+help: type parameter declared here
+  --> $DIR/issue-64662.rs:6:14
+   |
+LL | const fn foo<T>() -> isize {
+   |              ^
 
 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 8b1d4e6c07c..e58c9d3116a 100644
--- a/src/test/ui/error-codes/E0401.stderr
+++ b/src/test/ui/error-codes/E0401.stderr
@@ -37,6 +37,12 @@ error[E0282]: type annotations needed
    |
 LL |     bfnr(x);
    |     ^^^^ cannot infer type for type parameter `U` declared on the function `bfnr`
+   |
+help: type parameter declared here
+  --> $DIR/E0401.rs:4:13
+   |
+LL |     fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) {
+   |             ^
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/inference/erase-type-params-in-label.stderr b/src/test/ui/inference/erase-type-params-in-label.stderr
index d0b06cde9d6..51fac5f79df 100644
--- a/src/test/ui/inference/erase-type-params-in-label.stderr
+++ b/src/test/ui/inference/erase-type-params-in-label.stderr
@@ -6,6 +6,11 @@ LL |     let foo = foo(1, "");
    |         |
    |         consider giving `foo` the explicit type `Foo<_, _, W, Z>`, where the type parameter `W` is specified
    |
+help: type parameter declared here
+  --> $DIR/erase-type-params-in-label.rs:25:14
+   |
+LL | fn foo<T, K, W: Default, Z: Default>(t: T, k: K) -> Foo<T, K, W, Z> {
+   |              ^
    = note: cannot satisfy `_: Default`
 note: required by a bound in `foo`
   --> $DIR/erase-type-params-in-label.rs:25:17
@@ -25,6 +30,11 @@ LL |     let bar = bar(1, "");
    |         |
    |         consider giving `bar` the explicit type `Bar<_, _, Z>`, where the type parameter `Z` is specified
    |
+help: type parameter declared here
+  --> $DIR/erase-type-params-in-label.rs:14:14
+   |
+LL | fn bar<T, K, Z: Default>(t: T, k: K) -> Bar<T, K, Z> {
+   |              ^
    = note: cannot satisfy `_: Default`
 note: required by a bound in `bar`
   --> $DIR/erase-type-params-in-label.rs:14:17
diff --git a/src/test/ui/inference/issue-86162-1.stderr b/src/test/ui/inference/issue-86162-1.stderr
index 8d6f50748cb..edf97c0aed4 100644
--- a/src/test/ui/inference/issue-86162-1.stderr
+++ b/src/test/ui/inference/issue-86162-1.stderr
@@ -4,6 +4,11 @@ error[E0283]: type annotations needed
 LL |     foo(gen()); //<- Do not suggest `foo::<impl Clone>()`!
    |     ^^^ cannot infer type for type parameter `impl Clone` declared on the function `foo`
    |
+help: type parameter declared here
+  --> $DIR/issue-86162-1.rs:3:11
+   |
+LL | fn foo(x: impl Clone) {}
+   |           ^^^^^^^^^^
    = note: cannot satisfy `_: Clone`
 note: required by a bound in `foo`
   --> $DIR/issue-86162-1.rs:3:16
diff --git a/src/test/ui/inference/issue-86162-2.stderr b/src/test/ui/inference/issue-86162-2.stderr
index 5f80c595628..c642ebb0576 100644
--- a/src/test/ui/inference/issue-86162-2.stderr
+++ b/src/test/ui/inference/issue-86162-2.stderr
@@ -4,6 +4,11 @@ error[E0283]: type annotations needed
 LL |     Foo::bar(gen()); //<- Do not suggest `Foo::bar::<impl Clone>()`!
    |     ^^^^^^^^ cannot infer type for type parameter `impl Clone` declared on the associated function `bar`
    |
+help: type parameter declared here
+  --> $DIR/issue-86162-2.rs:8:15
+   |
+LL |     fn bar(x: impl Clone) {}
+   |               ^^^^^^^^^^
    = note: cannot satisfy `_: Clone`
 note: required by a bound in `Foo::bar`
   --> $DIR/issue-86162-2.rs:8:20
diff --git a/src/test/ui/issues/issue-6458.stderr b/src/test/ui/issues/issue-6458.stderr
index f1a982616a4..f548692d785 100644
--- a/src/test/ui/issues/issue-6458.stderr
+++ b/src/test/ui/issues/issue-6458.stderr
@@ -3,6 +3,12 @@ error[E0282]: type annotations needed
    |
 LL |    foo(TypeWithState(marker::PhantomData));
    |    ^^^ cannot infer type for type parameter `State` declared on the function `foo`
+   |
+help: type parameter declared here
+  --> $DIR/issue-6458.rs:6:12
+   |
+LL | pub fn foo<State>(_: TypeWithState<State>) {}
+   |            ^^^^^
 
 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 1219badc5b3..2aa2b0e6a3c 100644
--- a/src/test/ui/missing/missing-items/missing-type-parameter.stderr
+++ b/src/test/ui/missing/missing-items/missing-type-parameter.stderr
@@ -3,6 +3,12 @@ error[E0282]: type annotations needed
    |
 LL |     foo();
    |     ^^^ cannot infer type for type parameter `X` declared on the function `foo`
+   |
+help: type parameter declared here
+  --> $DIR/missing-type-parameter.rs:1:8
+   |
+LL | fn foo<X>() { }
+   |        ^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr b/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr
index b59a3818e70..a4cfee55633 100644
--- a/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr
+++ b/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr
@@ -5,6 +5,12 @@ LL |     let _ = f;
    |         -   ^ cannot infer type for type parameter `A` declared on the function `f`
    |         |
    |         consider giving this pattern the explicit type `fn() -> A`, where the type parameter `A` is specified
+   |
+help: type parameter declared here
+  --> $DIR/fn-needing-specified-return-type-param.rs:1:6
+   |
+LL | fn f<A>() -> A { unimplemented!() }
+   |      ^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr b/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr
index 9fd81b56bf1..da746134710 100644
--- a/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr
+++ b/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr
@@ -3,6 +3,12 @@ error[E0282]: type annotations needed
    |
 LL |     test(22, std::default::Default::default());
    |     ^^^^ cannot infer type for type parameter `U` declared on the function `test`
+   |
+help: type parameter declared here
+  --> $DIR/multidispatch-convert-ambig-dest.rs:20:11
+   |
+LL | fn test<T,U>(_: T, _: U)
+   |           ^
 
 error[E0283]: type annotations needed
   --> $DIR/multidispatch-convert-ambig-dest.rs:26:5
@@ -10,6 +16,11 @@ error[E0283]: type annotations needed
 LL |     test(22, std::default::Default::default());
    |     ^^^^ cannot infer type for type parameter `U` declared on the function `test`
    |
+help: type parameter declared here
+  --> $DIR/multidispatch-convert-ambig-dest.rs:20:11
+   |
+LL | fn test<T,U>(_: T, _: U)
+   |           ^
 note: multiple `impl`s satisfying `i32: Convert<_>` found
   --> $DIR/multidispatch-convert-ambig-dest.rs:8:1
    |
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 d60ca4a4932..501fa7c8c67 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
@@ -3,6 +3,12 @@ error[E0282]: type annotations needed
    |
 LL |     foo();
    |     ^^^ cannot infer type for type parameter `T` declared on the function `foo`
+   |
+help: type parameter declared here
+  --> $DIR/unbounded-type-param-in-fn-with-assoc-type.rs:3:8
+   |
+LL | fn foo<T, U = u64>() -> (T, U) {
+   |        ^
 
 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 45d879d8d56..d01c3a7d4e2 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
@@ -3,6 +3,12 @@ error[E0282]: type annotations needed
    |
 LL |     foo();
    |     ^^^ cannot infer type for type parameter `T` declared on the function `foo`
+   |
+help: type parameter declared here
+  --> $DIR/unbounded-type-param-in-fn.rs:1:8
+   |
+LL | fn foo<T>() -> T {
+   |        ^
 
 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 f7dfb845238..64fdbfe7db4 100644
--- a/src/test/ui/type/type-annotation-needed.stderr
+++ b/src/test/ui/type/type-annotation-needed.stderr
@@ -4,6 +4,11 @@ error[E0283]: type annotations needed
 LL |     foo(42);
    |     ^^^ cannot infer type for type parameter `T` declared on the function `foo`
    |
+help: type parameter declared here
+  --> $DIR/type-annotation-needed.rs:1:8
+   |
+LL | fn foo<T: Into<String>>(x: i32) {}
+   |        ^
    = note: cannot satisfy `_: Into<String>`
 note: required by a bound in `foo`
   --> $DIR/type-annotation-needed.rs:1:11