Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion library/alloc/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions tests/ui/traits/generic-cow-inference-regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading