-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Cloning an Arc with a Trait-Object tries to Clone the Trait-Object #15125
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
Comments
This appears to be a problem with autoderef. For example, this code compiles just fine: use std::sync::Arc;
trait TestTrait: Clone {}
pub struct Shared {
pub thing: Arc<Box<TestTrait + Send + Share>>
}
fn clone<T: Clone>(t: &T) -> T { t.clone() }
impl Clone for Shared {
fn clone(&self) -> Shared {
Shared {
thing: clone(&self.thing),
}
}
} In other words, the error is legitimate, you're just not calling the method you expecting. It appears the invocation of |
That's what I guessed, and in fact I used that same workaround to make this code work. Is this the expected behavior? |
I would suspect that this is a bug, I would also suspect that those such as @pnkfelix, @nick29581, or @nikomatsakis would know more than me. |
This is closed under new auto-deref semantics. |
internal: support `#[rustc_coinductive]` rust-lang#100386 changed the trait solver so that `Sized` is treated as coinductive trait, just like auto traits. This is now controlled by the perma-unstable `#[rustc_coinductive]` attribute (rust-lang#108033), which this PR adds support for. In practice, I don't think this matters much if at all. Currently we don't give chalk enough information so chalk cannot precisely (dis)prove `Sized` bounds.
Revert "Support `#[rustc_coinductive]`" Reverts rust-lang#15125, addresses rust-lang/rust-analyzer#15125 (comment) I'll add the support again once I figure out the problem.
This will compile:
But adding a
:Clone
bound to theTestTrait
definition like so:Fails with:
I think this is just a name resolution issue, but I'm not sure why this happens.
The text was updated successfully, but these errors were encountered: