-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Your crate will unfortunately stop compiling once rust-lang/rust#121848 is merged. It unintentionally relies on an unsound bug of the type system which we are now fixing: rust-lang/rust#114061.
derive-visitor/derive-visitor/src/lib.rs
Lines 538 to 544 in 39dc342
impl<T> Drive for T | |
where | |
T: 'static, | |
// HRTB, because this needs to be true for late-bound lifetimes, | |
// as both &self and &visitor have anonymous lifetimes. | |
for<'a> &'a T: IntoIterator, | |
for<'a> <&'a T as IntoIterator>::Item: DerefAndDrive, |
This can overlap with the following impl
derive-visitor/derive-visitor/src/lib.rs
Lines 566 to 568 in 39dc342
impl<T> Drive for Box<T> | |
where | |
T: Drive, |
causing Box<Local>
to implement Drive
using two separate overlapping impls in the following example:
use std::iter;
struct Local;
impl<'a> IntoIterator for &'a Box<Local> {
type IntoIter = iter::Once<&'a ()>;
type Item = &'a ();
fn into_iter(self) -> Self::IntoIter {
iter::once(&())
}
}
impl derive_visitor::Drive for Local {
fn drive<V>(&self, _: &mut V) {}
}
fn impls_drive<T: derive_visitor::Drive>() {}
fn main() {
impls_drive::<Box<Local>>();
}
The underlying issue is that, during the coherence overlap check, we consider for<'a> <&'a Box<_> as IntoIterator>::Item: DerefAndDrive
to never apply, even though as shown above, it is possible to writean impl so that it does.
I think that there is unfortunately no way to fix the new error except by remove the blanket impl. I apologize for the this.