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

Make it usable with 1.82.0+ #2

Closed
wants to merge 7 commits into from
Closed

Make it usable with 1.82.0+ #2

wants to merge 7 commits into from

Conversation

bonzini
Copy link
Owner

@bonzini bonzini commented Nov 4, 2024

No description provided.

@bonzini bonzini force-pushed the stable branch 8 times, most recently from d9f5661 to 07bd17e Compare November 4, 2024 15:39
@bonzini bonzini force-pushed the stable branch 3 times, most recently from 3150975 to eb1a8b4 Compare November 19, 2024 16:00
@bonzini bonzini force-pushed the stable branch 14 times, most recently from 87f96df to 0251607 Compare November 26, 2024 11:48
The kernel version of pinned_init implemented InPlaceWrite on UniqueArc,
not Arc.  This ensures that InPlaceWrite is not writing to a shared Arc.
Userspace does not have this facility and therefore cannot lift the
kernel implementation of InPlaceWrite directly into Arc<>.

One possibility would be to use Arc::get_mut(), though this would introduce
a panic in the case where the Arc is shared.  So just revert part of
commit 6841b61 ("rust: init: add `write_[pin_]init` functions", 2024-11-22).

Suggested-by: Benno Lossin <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Instead of using an unstable feature use unreachable_unchecked() to
enable optimization.

Suggested-by: Benno Lossin <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
The only dependency of the InPlaceInit trait on the allocator API is the
AllocError type.  Replace it with Infallible instead, i.e. allow any
error as long as it has an "impl From<Infallible> for MyError" - which
can have a trivial implementation as seen in examples/rror.rs.

While admittedly of limited usefulness due to orphan rules, this is
a first step towards allowing usage of pinned_init entirely without
the allocator API, and therefore on stable Rust.

Signed-off-by: Paolo Bonzini <[email protected]>
Memory allocation (i.e. the Box and Arc) can be present even without the
allocator_api.  Allow feature = "std" when the code is simply checking for
the existence of Box and Arc, and the allocator API is not used.

Signed-off-by: Paolo Bonzini <[email protected]>
When compiling without allocator_api, assume that allocations cannot fail.
This way, nightly Rust features are not absolutely needed for pinned_init,
and it can be used with stable Rust; right now the minimum supported Rust
version is 1.82.0, where the new_uninit version was stabilized.

Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
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.

1 participant