forked from Rust-for-Linux/pinned-init
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d9f5661
to
07bd17e
Compare
3150975
to
eb1a8b4
Compare
87f96df
to
0251607
Compare
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]>
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.