-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
No drop flag check for DST structs #16758
Comments
@nrc is this still relevant today? |
Yes, afaik. cc @pnkfelix |
Does this mean if i get:
Then I will get a memory leak? |
add missing spaces in #16758 warning I should probably add a test.
some relevant recent discussion from |
Just hit this when coercing a (Aside: it is of course illegal to coerce a Here's a small example that produces this warning: use std::sync::RwLock;
use std::boxed::Box;
trait Trait {}
struct Thing;
impl Trait for Thing {}
fn main() {
let _: Box<RwLock<Trait>> = Box::new(RwLock::new(Thing));
} Will I get a memory leak with this code? |
This should no longer be relevant after #35764 lands since it will remove in-struct drop flags |
Should this warning be removed now? Non-zeroing drops have landed, so there isn't a flag to check. |
Sure enough. There is no such a thing as a drop flag in the MIR (1.13+) universe. |
Update Cargo.lock
Since drop flags come after all named fields and the last field in a DST struct is unsized, finding the drop flag is a bit tricky. Therefore, it is currently not checked. A possible fix is to find the alignment by taking the size of the struct from its vtable and subtracting the size of the drop flag. However, since the plan is to remove the drop flag anyway (#5016), I have just left a FIXME and issue a warning when we skip the check.
cc @pnkfelix
The text was updated successfully, but these errors were encountered: