about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTakayuki Maeda <41065217+TaKO8Ki@users.noreply.github.com>2022-05-11 19:18:02 +0900
committerTakayuki Maeda <41065217+TaKO8Ki@users.noreply.github.com>2022-05-11 19:18:02 +0900
commitdaeec7e22de6a99a5440ddf401f3fc16756cd64a (patch)
treef2bc4c636631782bf0b1cc9488d8328f34d6eb13 /src
parentcb121987158d69bb894ba1bcc21dc45d1e0a488f (diff)
stop suggesting non-existing fully qualified paths
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.rs24
-rw-r--r--src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr35
2 files changed, 59 insertions, 0 deletions
diff --git a/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.rs b/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.rs
new file mode 100644
index 00000000000..538e74ee1b0
--- /dev/null
+++ b/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.rs
@@ -0,0 +1,24 @@
+struct A<T>(T);
+struct B;
+
+trait I<T> {}
+impl I<i32> for B {}
+impl I<u32> for B {}
+
+trait V<U> {
+    fn method(self) -> U;
+}
+
+impl<T, U> V<U> for A<T>
+where
+    T: I<U>,
+{
+    fn method(self) -> U { unimplemented!() }
+}
+
+fn main() {
+    let a = A(B);
+    a.method();
+    //~^ ERROR type annotations needed
+    //~| ERROR type annotations needed
+}
diff --git a/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr b/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr
new file mode 100644
index 00000000000..65f2d99417f
--- /dev/null
+++ b/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr
@@ -0,0 +1,35 @@
+error[E0282]: type annotations needed
+  --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7
+   |
+LL |     a.method();
+   |     --^^^^^^--
+   |     | |
+   |     | cannot infer type for type parameter `U` declared on the trait `V`
+   |     this method call resolves to `U`
+
+error[E0283]: type annotations needed
+  --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7
+   |
+LL |     a.method();
+   |     --^^^^^^--
+   |     | |
+   |     | cannot infer type for type parameter `U`
+   |     this method call resolves to `U`
+   |
+note: multiple `impl`s satisfying `B: I<_>` found
+  --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:5:1
+   |
+LL | impl I<i32> for B {}
+   | ^^^^^^^^^^^^^^^^^
+LL | impl I<u32> for B {}
+   | ^^^^^^^^^^^^^^^^^
+note: required because of the requirements on the impl of `V<_>` for `A<B>`
+  --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:12:12
+   |
+LL | impl<T, U> V<U> for A<T>
+   |            ^^^^     ^^^^
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0282, E0283.
+For more information about an error, try `rustc --explain E0282`.