about summary refs log tree commit diff
path: root/tests/ui/wf
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-04-09 10:19:48 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-04-09 10:21:29 +0000
commitc8f6e03c1570200dbb99587fb257d371aa7447b3 (patch)
tree77028ca81cf1a63e8e63f4ad44c3fdc5f2e0a99a /tests/ui/wf
parentbd12986fd6659a3091cff7694b8225374f4a26fe (diff)
downloadrust-c8f6e03c1570200dbb99587fb257d371aa7447b3.tar.gz
rust-c8f6e03c1570200dbb99587fb257d371aa7447b3.zip
Add regression test
Diffstat (limited to 'tests/ui/wf')
-rw-r--r--tests/ui/wf/conflicting-impls.rs22
-rw-r--r--tests/ui/wf/conflicting-impls.stderr41
2 files changed, 63 insertions, 0 deletions
diff --git a/tests/ui/wf/conflicting-impls.rs b/tests/ui/wf/conflicting-impls.rs
new file mode 100644
index 00000000000..c387199a8bf
--- /dev/null
+++ b/tests/ui/wf/conflicting-impls.rs
@@ -0,0 +1,22 @@
+//@ edition: 2021
+
+struct Ty;
+
+impl TryFrom<Ty> for u8 {
+    type Error = Ty;
+    fn try_from(_: Ty) -> Result<Self, Self::Error> {
+        //~^ ERROR type annotations needed
+        loop {}
+    }
+}
+
+impl TryFrom<Ty> for u8 {
+    //~^ ERROR conflicting implementations of trait
+    type Error = Ty;
+    fn try_from(_: Ty) -> Result<Self, Self::Error> {
+        //~^ ERROR type annotations needed
+        loop {}
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/wf/conflicting-impls.stderr b/tests/ui/wf/conflicting-impls.stderr
new file mode 100644
index 00000000000..69f48f69bfb
--- /dev/null
+++ b/tests/ui/wf/conflicting-impls.stderr
@@ -0,0 +1,41 @@
+error[E0119]: conflicting implementations of trait `TryFrom<Ty>` for type `u8`
+  --> $DIR/conflicting-impls.rs:12:1
+   |
+LL | impl TryFrom<Ty> for u8 {
+   | ----------------------- first implementation here
+...
+LL | impl TryFrom<Ty> for u8 {
+   | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8`
+
+error[E0282]: type annotations needed
+  --> $DIR/conflicting-impls.rs:7:5
+   |
+LL |     fn try_from(_: Ty) -> Result<Self, Self::Error> {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
+   |
+note: the requirement `_ <: _` appears on the `impl`'s method `try_from` but not on the corresponding trait's method
+  --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
+   |
+   = note: in this trait
+  ::: $SRC_DIR/core/src/convert/mod.rs:LL:COL
+   |
+   = note: this trait's method doesn't have the requirement `_ <: _`
+
+error[E0282]: type annotations needed
+  --> $DIR/conflicting-impls.rs:14:5
+   |
+LL |     fn try_from(_: Ty) -> Result<Self, Self::Error> {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
+   |
+note: the requirement `_ <: _` appears on the `impl`'s method `try_from` but not on the corresponding trait's method
+  --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
+   |
+   = note: in this trait
+  ::: $SRC_DIR/core/src/convert/mod.rs:LL:COL
+   |
+   = note: this trait's method doesn't have the requirement `_ <: _`
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0119, E0282.
+For more information about an error, try `rustc --explain E0119`.