Skip to content
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

[stdlib] Use ownership ops in Uninit to remove pointer indirection. #3453

Open
wants to merge 1 commit into
base: nightly
Choose a base branch
from

Conversation

helehex
Copy link
Contributor

@helehex helehex commented Sep 5, 2024

The ownership ops provide a more clear implementation than pop.array, and allows the pointer indirection to be removed.
This makes the inner field of UnsafeMaybeUninitialized just a ElementType instead of a pop.array<...>
Because we get an error when marking subobjects as destroyed, i used a capturing function within the types destructor to make sure the underlying values destructor isn't called.
I had to bump up the move counter check in one of the tests, because of how the implementation changed, but i'm pretty sure the actual move gets optimized away, even if the move counter doesn't.

…zed`, and remove unnecessary pointer indirection within the type

Signed-off-by: Max Brylski <helehex@gmail.com>
@helehex helehex requested a review from a team as a code owner September 5, 2024 21:38
@@ -89,7 +89,7 @@ def test_maybe_uninitialized_move_from_pointer():
_ = a^

# a is uninitialized now. Thankfully, we're working with trivial types
assert_equal(b.assume_initialized().move_count, 1)
assert_equal(b.assume_initialized().move_count, 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite strange indeed. Can you add a unit test with a non-movable type and see if it works correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once I figure out stdlib dev with magic, i'll add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants