-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
HRTB bounds not resolving correctly, but they do work if you introduce a reference. #85636
Comments
Interestingly, if you want this to work for Clone, you can just introduce |
I need some further trickery to make it work for #[derive(Clone)]
#[repr(transparent)]
pub struct Wrap<T>(T);
impl<T> Wrap<T> {
fn wrap(t: &T) -> &Self {
unsafe { std::mem::transmute(t) }
}
}
/// Clone requires that the cart derefs to the same address after it is cloned. This works for Rc, Arc, and &'a T.
/// For all other cart types, clone `.baking_cart()` and re-use `attach_to_cart()`.
impl<Y: for<'a> Yokeable<'a>, T: ?Sized> Clone for Yoke<Y, Rc<T>>
where
for<'a> Wrap<<Y as Yokeable<'a>>::Output>: Clone,
{
fn clone(&self) -> Self {
Yoke {
yokeable: unsafe { Y::make(Wrap::wrap(self.get()).clone().0) },
cart: self.cart.clone(),
}
}
} |
…komatsakis Normalize projections under binders Fixes rust-lang#70243 Fixes rust-lang#70120 Fixes rust-lang#62529 Fixes rust-lang#87219 Issues to followup on after (probably fixed, but no test added here): rust-lang#76956 rust-lang#56556 rust-lang#79207 rust-lang#85636 r? `@nikomatsakis`
Not completely fixed yet. Here is a different test case that still reproduces the error on nightly and beta: EDIT: Made the case a bit smaller: |
(happy to file this as a new issue @jackh726 if you'd prefer!) |
Yes, please new issue and tag me |
Refiled as #89196 |
Closing since other issue has been filed. |
I'm trying to write Debug impls for the
yoke
crate:Non-compiling code
(playpen)
This code fails to compile:
However, swapping the
for<'a> <Y as Yokeable<'a>>::Output: fmt::Debug
bound withfor<'a> &'a <Y as Yokeable<'a>>::Output: fmt::Debug
has it start compiling again.Compiling code
(playpen)
Note that
Yoke::get()
does not need to exist to reproduce this bug, however it helps motivate why an HRTB bound is necessary.It seems like both cases should successfully compile, all
Cow<u8>
s implement Debug.cc @tmandry @eddyb
The text was updated successfully, but these errors were encountered: