-
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
Add regression tests to ensure stable drop order #43125
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
src/test/run-pass/rfc1857.rs
Outdated
assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); | ||
|
||
// Panic during struct construction means that fields are treated as local variables | ||
// Therefore they are dropped in reverse order of declaration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not entirely correct. As far as I know, here the fields are dropped in reverse order of initialization (not declaration) -- that is, If you swapped the lines with x:
and y:
below, x
would be dropped before y
. I think it would be good to have tests, for structs and enum-struct variants, which use different initialization and declaration orders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right... I always confuse these terms... I am going to correct the comment and add more tests.
Just pushed two tests more to ensure different field initialization order behaves as expected |
I would consider merging this with the |
@arielb1 done! |
@bors r+ rollup |
📌 Commit f86e433 has been approved by |
Add regression tests to ensure stable drop order Work towards rust-lang#43034 I think this is all we need to do on the testing front regarding RFC 1857
Work towards #43034
I think this is all we need to do on the testing front regarding RFC 1857