diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index d2ab5412eeabc..d982e46e08afc 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -333,7 +333,8 @@ impl Cow<'_, B> { // #[rustc_const_unstable(feature = "const_convert", issue = "143773")] #[stable(feature = "rust1", since = "1.0.0")] impl Deref for Cow<'_, B> -// where +where + B::Owned: Borrow, // B::Owned: [const] Borrow, { type Target = B; diff --git a/tests/ui/traits/generic-cow-inference-regression.rs b/tests/ui/traits/generic-cow-inference-regression.rs index 6fd4715f85bbd..823570ab8d11a 100644 --- a/tests/ui/traits/generic-cow-inference-regression.rs +++ b/tests/ui/traits/generic-cow-inference-regression.rs @@ -5,9 +5,12 @@ use std::borrow::{Cow, Borrow}; -pub fn generic_deref<'a, T: ToOwned, 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, U>(cow: Cow<'a, T>) { +// let _: &T = &cow; +// } pub fn generic_borrow<'a, T: ToOwned, U>(cow: Cow<'a, T>) { let _: &T = cow.borrow();