-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
internal UnsafeCell causes references to be dropped immediately #36063
Comments
This is because you are taking an The way to fix this is to stop requiring a |
Hey @arielb1, thanks for taking a look at this. I don't understand several points you are making though.
When is
but the Pool is a local variable too, I don't understand why it can't just live as long as the pool (I am even telling it to live as long as the pool with the lifetime)
I'm not sure what I should replace it with. Please help, I am really confused. |
nevermind, I have found a way around it -- I just don't use UnsafeCell at all. I added the file |
I really do still think this is a bug -- try to get |
This has been driving me crazy and I have finally found the root cause of the bug.
I have tried to compile with all of these versions, so I can be pretty sure that this bug is NOT a regression.
The source code that details the bug is here:
https://github.com/vitiral/notes/tree/rust_bug/rust/lifesucks/src
You can see I have created 3 versions of roughly the same code in increasing complexity:
simple.rs
contains an ultra simple version of what I am trying to do: have some data behind a pool that allocates to a mutex. In this case, it doesn't even support dynamic types. This compilescomplex.rs
is a more complete version of the same thing and this also compilesvery_complex.rs
is almost idential tocomplex.rs
but it hides it's data behind an UnsafeCell. this does not compileFor
very_complex.rs
the compiler gives these errors:even though that section of code looks like this:
In other words, there is no way this is because of #15023 (also, it works fine in the other versions).
It would be great if someone could take a look, this has been driving me absolutely crazy today.
The text was updated successfully, but these errors were encountered: