-
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
Destructor for @Trait
is not run in certain circumstances
#10802
Labels
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Comments
It's no longer possible to cast to I tried to reproduced this bug using |
@flaper87 is there a testcase which covers this? |
@cmr I had seen it before but I can't find it anymore. Re-opening and flagging as needs test: struct DroppableStruct;
impl Drop for DroppableStruct {
fn drop(&mut self) {
println!("Dropping");
}
}
trait MyTrait { }
impl MyTrait for ~DroppableStruct {}
struct Whatever { w: ~MyTrait }
impl Whatever {
fn new(w: ~MyTrait) -> Whatever {
Whatever { w: w }
}
}
fn main() {
let f = ~DroppableStruct;
let _a = Whatever::new(~f as ~MyTrait);
} |
bors
added a commit
that referenced
this issue
Apr 28, 2014
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
May 20, 2023
Rustup r? `@ghost` changelog: none
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
I'm not sure if this is a duplicate of an existing issue, there are many destructor related issues open already. But anyways, here it is:
This doesn't run the destructor of
DroppableStruct
. This is pretty much as minimal as I could get the example, many changes make it work. E.g. changing the main function body to:makes the destructor work. Also, not saving the
Whatever
struct in a variable makes it work. Also, not saving the@MyTrait
inWhatever
makes it work. Good luck.Update: removed
mut
, was not relevant.Update2: added a field to the struct to show it's not an issue about zero-sized structs.
The text was updated successfully, but these errors were encountered: