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
21 changes: 12 additions & 9 deletions library/alloc/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ use crate::fmt;
#[cfg(not(no_global_oom_handling))]
use crate::string::String;

// FIXME(inference): const bounds removed due to inference regressions found by crater;
// see https://github.com/rust-lang/rust/issues/147964
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl<'a, B: ?Sized> const Borrow<B> for Cow<'a, B>
where
B: ToOwned,
B::Owned: [const] Borrow<B>,
impl<'a, B: ?Sized + ToOwned> Borrow<B> for Cow<'a, B>
// where
// B::Owned: [const] Borrow<B>,
{
fn borrow(&self) -> &B {
&**self
Expand Down Expand Up @@ -327,11 +328,13 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
}
}

// FIXME(inference): const bounds removed due to inference regressions found by crater;
// see https://github.com/rust-lang/rust/issues/147964
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
where
B::Owned: [const] Borrow<B>,
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
// where
// B::Owned: [const] Borrow<B>,
{
type Target = B;

Expand Down
20 changes: 20 additions & 0 deletions tests/ui/traits/generic-cow-inference-regression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//@ run-pass

// regression test for #147964:
// constification of these traits resulted in inference errors due to additional where clauses

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

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

pub fn generic_as_ref<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
let _: &T = cow.as_ref();
}

fn main() {}
Loading