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

Remove unsafe #7667

Merged
merged 2 commits into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions third_party/move/move-symbol-pool/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ impl Pool {
/// Allocates a contiguous array of buckets on the heap. As strings are
/// inserted into the pool, buckets in this array are filled with an entry.
pub(crate) fn new() -> Self {
let vec = std::mem::ManuallyDrop::new(vec![0_usize; NB_BUCKETS]);
Self(unsafe { Box::from_raw(vec.as_ptr() as *mut [Bucket; NB_BUCKETS]) })
// Using const INIT, works around the fact that [None; NB_BUCKETS] not being possible
// because Bucket is not Copy.
const INIT: Bucket = None;
Self(Box::new([INIT; NB_BUCKETS]))
}

/// Computes the hash value of a string, which is used to determine both
Expand Down