Skip to content

Commit faf3e0b

Browse files
committed
Further revert Deref for Cow to its 1.90.0 state
ref: #147964 (comment)
1 parent 40c4f6d commit faf3e0b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

library/alloc/src/borrow.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
333333
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
334334
#[stable(feature = "rust1", since = "1.0.0")]
335335
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
336-
// where
336+
where
337+
B::Owned: Borrow<B>,
337338
// B::Owned: [const] Borrow<B>,
338339
{
339340
type Target = B;

tests/ui/traits/generic-cow-inference-regression.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55

66
use std::borrow::{Cow, Borrow};
77

8-
pub fn generic_deref<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
9-
let _: &T = &cow;
10-
}
8+
// This won't work even with the non-const bound on `Deref` like 1.90.0, although note
9+
// as well that no such bound existed until 1.57 started `~const` experiments.
10+
//
11+
// pub fn generic_deref<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
12+
// let _: &T = &cow;
13+
// }
1114

1215
pub fn generic_borrow<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
1316
let _: &T = cow.borrow();

0 commit comments

Comments
 (0)