-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Regression: implementing Clone
for trait objects
#61759
Comments
This also works if you extract the reference out of the box inside the impl Clone for Box<dyn CBFn> {
fn clone(&self) -> Self {
self.as_ref().clone_boxed()
}
} It looks like Rust sees that |
Thanks, @KrishnaSannasi. This makes sense, but I find it disturbing that the behavior changed in one of the recent compiler releases, potentially breaking software that relied on the old behavior. I wonder if this is deliberate or a side effect of some other change. |
This is likely a side effect of changes/optimizations to how blanket trait impls interact with each other. |
This looks like fallout from #59500. |
pre-triage: P-high (for bisection to verify hypothesis that this was injected by #59500), unnominating, assigning to self. |
During the T-compiler pre-meeting triage yesterday, @Centril said that if this is an injection from #59500, and it is expected fallout from that. @lqd has confirmed this. In addition to using Closing as not-a-bug. |
I just came to a similar issue. This code was helpful to me. Thanks! |
The following code used to work with rustc 1.32 and earlier, but it crashes with stack overflow due to infinite recursion in 1.35
(Playground)
Errors:
Update
It does work correctly with a slightly modified
main
usingas_ref()
to explicitly extract reference out of the box.The text was updated successfully, but these errors were encountered: