Closed
Description
So I had a trait system in my (nightly) code for a while now that utilized specialization, but it no longer seems to be working after a recent update:
#![feature(specialization)]
trait Trait1 { type Selection: PartialEq; }
trait Trait2: PartialEq<Self> {}
impl<T:Trait2> Trait1 for T { default type Selection = T; }
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/main.rs:1:12
|
1 | #![feature(specialization)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
error[E0277]: can't compare `T` with `<T as Trait1>::Selection`
--> src/main.rs:6:31
|
3 | trait Trait1 { type Selection: PartialEq; }
| -------------------------- required by `Trait1::Selection`
...
6 | impl<T:Trait2> Trait1 for T { default type Selection = T; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `T == <T as Trait1>::Selection`
|
= help: the trait `std::cmp::PartialEq<<T as Trait1>::Selection>` is not implemented for `T`
help: consider further restricting this bound
|
6 | impl<T:Trait2 + std::cmp::PartialEq<<T as Trait1>::Selection>> Trait1 for T { default type Selection = T; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0277`.
Now, I haven't been following the development of the specialization feature too closely, so it is possible that this is somehow actually intended and I am missing something. However, given that this previously compiled and ran just fine a couple weeks ago and given that the specialization incomplete warning was only added recently, I am inclined to think that it is probably a regression of some sort.
Meta things
compiler version:
$rustc --version --verbose
rustc 1.46.0-nightly (7750c3d46 2020-06-26)
binary: rustc
commit-hash: 7750c3d46bc19784adb1ee6e37a5ec7e4cd7e772
commit-date: 2020-06-26
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0