Auto merge of #148216 - cuviper:stable-next, r=BoxyUwU,jackh726

[stable] Further revert `Deref for Cow` to its 1.90.0 state

It's not clear whether it breaks anything to *not* have this bound,
but the conservative choice is to match the state as of 1.90.0.

See also:
https://github.com/rust-lang/rust/issues/147964#issuecomment-3446420995
https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/Can.20this.20change.20break.20code.20in.201.2E91.3F/with/547528362
This commit is contained in:
bors
2025-10-28 16:34:16 +00:00
2 changed files with 8 additions and 4 deletions

View File

@@ -333,7 +333,8 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
// #[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;

View File

@@ -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();