Skip to content

min_specialization: cannot specialize on Binder(ProjectionPredicate(..)) #98777

Closed
@CAD97

Description

@CAD97

Given the following code: [playground]

#![feature(min_specialization)]

use std::borrow::Borrow;

pub trait IntoOwnedBorrow<Borrowed>: Borrow<Borrowed>
where
    Borrowed: ?Sized + ToOwned,
{
    fn into_owned(this: Self) -> Borrowed::Owned;
}

impl<T> IntoOwnedBorrow<T> for T
where
    T: ToOwned<Owned = T>,
{
    fn into_owned(this: Self) -> T {
        this
    }
}

impl<T> IntoOwnedBorrow<T> for T::Owned
where
    T: ?Sized + ToOwned,
{
    default fn into_owned(this: Self) -> T::Owned {
        this
    }
}

The current output is:

error: cannot specialize on `Binder(ProjectionPredicate(ProjectionTy { substs: [T], item_def_id: DefId(5:776 ~ alloc[55b1]::borrow::ToOwned::Owned) }, Ty(T)), [])`
  --> src/lib.rs:12:1
   |
12 | / impl<T> IntoOwnedBorrow<T> for T
13 | | where
14 | |     T: ToOwned<Owned = T>,
15 | | {
...  |
18 | |     }
19 | | }
   | |_^

Ideally the output should not reference the debug format of an internal type 🙂

@rustbot modify labels +F-specialization +A-specialization +requires-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-specializationArea: Trait impl specializationF-specialization`#![feature(specialization)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions