summaryrefslogtreecommitdiffstats
path: root/tests/ui/inference/need_type_info
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/inference/need_type_info')
-rw-r--r--tests/ui/inference/need_type_info/concrete-impl.rs3
-rw-r--r--tests/ui/inference/need_type_info/concrete-impl.stderr9
-rw-r--r--tests/ui/inference/need_type_info/issue-109905.rs25
-rw-r--r--tests/ui/inference/need_type_info/issue-109905.stderr15
4 files changed, 48 insertions, 4 deletions
diff --git a/tests/ui/inference/need_type_info/concrete-impl.rs b/tests/ui/inference/need_type_info/concrete-impl.rs
index 72e0e74f3..fc79e6201 100644
--- a/tests/ui/inference/need_type_info/concrete-impl.rs
+++ b/tests/ui/inference/need_type_info/concrete-impl.rs
@@ -7,10 +7,13 @@ struct Two;
struct Struct;
impl Ambiguous<One> for Struct {}
+//~^ NOTE multiple `impl`s satisfying `Struct: Ambiguous<_>` found
impl Ambiguous<Two> for Struct {}
fn main() {
<Struct as Ambiguous<_>>::method();
//~^ ERROR type annotations needed
+ //~| NOTE cannot infer type of the type parameter `A`
//~| ERROR type annotations needed
+ //~| NOTE infer type of the type parameter `A`
}
diff --git a/tests/ui/inference/need_type_info/concrete-impl.stderr b/tests/ui/inference/need_type_info/concrete-impl.stderr
index aa3296995..74c3f6cd5 100644
--- a/tests/ui/inference/need_type_info/concrete-impl.stderr
+++ b/tests/ui/inference/need_type_info/concrete-impl.stderr
@@ -1,20 +1,21 @@
error[E0282]: type annotations needed
- --> $DIR/concrete-impl.rs:13:5
+ --> $DIR/concrete-impl.rs:14:5
|
LL | <Struct as Ambiguous<_>>::method();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the trait `Ambiguous`
error[E0283]: type annotations needed
- --> $DIR/concrete-impl.rs:13:5
+ --> $DIR/concrete-impl.rs:14:5
|
LL | <Struct as Ambiguous<_>>::method();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the trait `Ambiguous`
|
note: multiple `impl`s satisfying `Struct: Ambiguous<_>` found
--> $DIR/concrete-impl.rs:9:1
|
LL | impl Ambiguous<One> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
LL | impl Ambiguous<Two> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/inference/need_type_info/issue-109905.rs b/tests/ui/inference/need_type_info/issue-109905.rs
new file mode 100644
index 000000000..99d10a5ea
--- /dev/null
+++ b/tests/ui/inference/need_type_info/issue-109905.rs
@@ -0,0 +1,25 @@
+// Test that we show the correct type parameter that couldn't be inferred and that we don't
+// end up stating nonsense like "type parameter `'a`" which we used to do.
+
+trait Trait<'a, T> {
+ fn m(self);
+}
+
+impl<'a, A> Trait<'a, A> for () {
+ fn m(self) {}
+}
+
+fn qualified() {
+ <() as Trait<'static, _>>::m(());
+ //~^ ERROR type annotations needed
+ //~| NOTE cannot infer type of the type parameter `T`
+
+}
+
+fn unqualified() {
+ Trait::<'static, _>::m(());
+ //~^ ERROR type annotations needed
+ //~| NOTE cannot infer type of the type parameter `T`
+}
+
+fn main() {}
diff --git a/tests/ui/inference/need_type_info/issue-109905.stderr b/tests/ui/inference/need_type_info/issue-109905.stderr
new file mode 100644
index 000000000..fcdd50f14
--- /dev/null
+++ b/tests/ui/inference/need_type_info/issue-109905.stderr
@@ -0,0 +1,15 @@
+error[E0282]: type annotations needed
+ --> $DIR/issue-109905.rs:13:5
+ |
+LL | <() as Trait<'static, _>>::m(());
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the trait `Trait`
+
+error[E0282]: type annotations needed
+ --> $DIR/issue-109905.rs:20:5
+ |
+LL | Trait::<'static, _>::m(());
+ | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the trait `Trait`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0282`.