about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-06-26 17:19:32 +0900
committerYuki Okushi <jtitor@2k36.org>2022-06-26 17:19:32 +0900
commit7e5aa3e5aa509806e0abe4d5ede3f49827d96849 (patch)
tree662d2a2c9af1f65a0a6b364b4d9eaf3af11939e6
parent639a655e11306116e8507d401a1262e87e1b23b7 (diff)
downloadrust-7e5aa3e5aa509806e0abe4d5ede3f49827d96849.tar.gz
rust-7e5aa3e5aa509806e0abe4d5ede3f49827d96849.zip
Add regression test for #79224
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
-rw-r--r--src/test/ui/specialization/min_specialization/issue-79224.rs24
-rw-r--r--src/test/ui/specialization/min_specialization/issue-79224.stderr29
2 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/specialization/min_specialization/issue-79224.rs b/src/test/ui/specialization/min_specialization/issue-79224.rs
new file mode 100644
index 00000000000..408732fe944
--- /dev/null
+++ b/src/test/ui/specialization/min_specialization/issue-79224.rs
@@ -0,0 +1,24 @@
+#![feature(min_specialization)]
+use std::fmt::{self, Display};
+
+pub enum Cow<'a, B: ?Sized + 'a, O = <B as ToOwned>::Owned>
+where
+    B: ToOwned,
+{
+    Borrowed(&'a B),
+    Owned(O),
+}
+
+impl ToString for Cow<'_, str> {
+    fn to_string(&self) -> String {
+        String::new()
+    }
+}
+
+impl<B: ?Sized> Display for Cow<'_, B> { //~ ERROR: the trait bound `B: Clone` is not satisfied [E0277]
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { //~ ERROR: the trait bound `B: Clone` is not satisfied [E0277]
+        write!(f, "foo")
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/specialization/min_specialization/issue-79224.stderr b/src/test/ui/specialization/min_specialization/issue-79224.stderr
new file mode 100644
index 00000000000..44c6ec1426b
--- /dev/null
+++ b/src/test/ui/specialization/min_specialization/issue-79224.stderr
@@ -0,0 +1,29 @@
+error[E0277]: the trait bound `B: Clone` is not satisfied
+  --> $DIR/issue-79224.rs:18:17
+   |
+LL | impl<B: ?Sized> Display for Cow<'_, B> {
+   |                 ^^^^^^^ the trait `Clone` is not implemented for `B`
+   |
+   = note: required because of the requirements on the impl of `ToOwned` for `B`
+help: consider further restricting this bound
+   |
+LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> {
+   |                +++++++++++++++++++
+
+error[E0277]: the trait bound `B: Clone` is not satisfied
+  --> $DIR/issue-79224.rs:19:5
+   |
+LL | /     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+LL | |         write!(f, "foo")
+LL | |     }
+   | |_____^ the trait `Clone` is not implemented for `B`
+   |
+   = note: required because of the requirements on the impl of `ToOwned` for `B`
+help: consider further restricting this bound
+   |
+LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> {
+   |                +++++++++++++++++++
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.