Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
CAD97 opened this issue Jul 1, 2022 · 0 comments · Fixed by #98782
Closed

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

CAD97 opened this issue Jul 1, 2022 · 0 comments · Fixed by #98782
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-specialization Area: Trait impl specialization F-specialization `#![feature(specialization)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@CAD97
Copy link
Contributor

CAD97 commented Jul 1, 2022

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

@CAD97 CAD97 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 1, 2022
@rustbot rustbot added A-specialization Area: Trait impl specialization F-specialization `#![feature(specialization)]` requires-nightly This issue requires a nightly compiler in some way. labels Jul 1, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 4, 2022
…r-span, r=oli-obk

Improve spans for specialization error

Fixes rust-lang#98777
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 4, 2022
…r-span, r=oli-obk

Improve spans for specialization error

Fixes rust-lang#98777
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 4, 2022
…r-span, r=oli-obk

Improve spans for specialization error

Fixes rust-lang#98777
@bors bors closed this as completed in da630de Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-specialization Area: Trait impl specialization F-specialization `#![feature(specialization)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants