Further revert Deref for Cow to its 1.90.0 state

ref: https://github.com/rust-lang/rust/issues/147964#issuecomment-3446420995
This commit is contained in:
Josh Stone
2025-10-28 08:41:14 -07:00
parent 40c4f6dfcd
commit faf3e0b589
2 changed files with 8 additions and 4 deletions
+2 -1
View File
@@ -333,7 +333,8 @@ pub fn into_owned(self) -> <B as ToOwned>::Owned {
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
#[stable(feature = "rust1", since = "1.0.0")]
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
// where
where
B::Owned: Borrow<B>,
// B::Owned: [const] Borrow<B>,
{
type Target = B;
@@ -5,9 +5,12 @@
use std::borrow::{Cow, Borrow};
pub fn generic_deref<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
let _: &T = &cow;
}
// This won't work even with the non-const bound on `Deref` like 1.90.0, although note
// as well that no such bound existed until 1.57 started `~const` experiments.
//
// pub fn generic_deref<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
// let _: &T = &cow;
// }
pub fn generic_borrow<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
let _: &T = cow.borrow();