Skip to content

Commit b8bb6f9

Browse files
authored
Rollup merge of #98525 - JohnTitor:issue-79224, r=compiler-errors
Add regression test for #79224 Closes #79224 r? `@compiler-errors` Signed-off-by: Yuki Okushi <[email protected]>
2 parents 57c3cee + 7e5aa3e commit b8bb6f9

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(min_specialization)]
2+
use std::fmt::{self, Display};
3+
4+
pub enum Cow<'a, B: ?Sized + 'a, O = <B as ToOwned>::Owned>
5+
where
6+
B: ToOwned,
7+
{
8+
Borrowed(&'a B),
9+
Owned(O),
10+
}
11+
12+
impl ToString for Cow<'_, str> {
13+
fn to_string(&self) -> String {
14+
String::new()
15+
}
16+
}
17+
18+
impl<B: ?Sized> Display for Cow<'_, B> { //~ ERROR: the trait bound `B: Clone` is not satisfied [E0277]
19+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { //~ ERROR: the trait bound `B: Clone` is not satisfied [E0277]
20+
write!(f, "foo")
21+
}
22+
}
23+
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error[E0277]: the trait bound `B: Clone` is not satisfied
2+
--> $DIR/issue-79224.rs:18:17
3+
|
4+
LL | impl<B: ?Sized> Display for Cow<'_, B> {
5+
| ^^^^^^^ the trait `Clone` is not implemented for `B`
6+
|
7+
= note: required because of the requirements on the impl of `ToOwned` for `B`
8+
help: consider further restricting this bound
9+
|
10+
LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> {
11+
| +++++++++++++++++++
12+
13+
error[E0277]: the trait bound `B: Clone` is not satisfied
14+
--> $DIR/issue-79224.rs:19:5
15+
|
16+
LL | / fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17+
LL | | write!(f, "foo")
18+
LL | | }
19+
| |_____^ the trait `Clone` is not implemented for `B`
20+
|
21+
= note: required because of the requirements on the impl of `ToOwned` for `B`
22+
help: consider further restricting this bound
23+
|
24+
LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> {
25+
| +++++++++++++++++++
26+
27+
error: aborting due to 2 previous errors
28+
29+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)