0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-21 15:04:33 -05:00

chore: bump rust-toolchain (#1408)

This commit is contained in:
Matt Mastracci 2024-03-01 10:28:17 -07:00 committed by GitHub
parent 508979cbd5
commit 63eea06a9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 80 additions and 96 deletions

View file

@ -67,16 +67,13 @@ jobs:
run: git config --global core.symlinks true run: git config --global core.symlinks true
- name: Clone repository - name: Clone repository
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
fetch-depth: 10 fetch-depth: 10
submodules: recursive submodules: recursive
- name: Install rust - name: Install rust
uses: hecrj/setup-rust-action@v1 uses: dsherret/rust-toolchain-file@v1
with:
components: clippy, rustfmt
rust-version: 1.66.1
- name: Install python - name: Install python
uses: actions/setup-python@v4 uses: actions/setup-python@v4

View file

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "1.71.0" channel = "1.76.0"
components = ["rustfmt", "clippy"] components = ["rustfmt", "clippy"]

View file

@ -957,7 +957,6 @@ impl Function {
pub fn create_code_cache(&self) -> Option<UniqueRef<CachedData<'static>>> { pub fn create_code_cache(&self) -> Option<UniqueRef<CachedData<'static>>> {
let code_cache = let code_cache =
unsafe { UniqueRef::try_from_raw(v8__Function__CreateCodeCache(self)) }; unsafe { UniqueRef::try_from_raw(v8__Function__CreateCodeCache(self)) };
#[cfg(debug_assertions)]
if let Some(code_cache) = &code_cache { if let Some(code_cache) = &code_cache {
debug_assert_eq!( debug_assert_eq!(
code_cache.buffer_policy(), code_cache.buffer_policy(),

View file

@ -1361,6 +1361,9 @@ pub(crate) struct IsolateAnnex {
isolate_mutex: Mutex<()>, isolate_mutex: Mutex<()>,
} }
unsafe impl Send for IsolateAnnex {}
unsafe impl Sync for IsolateAnnex {}
impl IsolateAnnex { impl IsolateAnnex {
fn new( fn new(
isolate: &mut Isolate, isolate: &mut Isolate,
@ -1395,9 +1398,6 @@ impl Debug for IsolateAnnex {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct IsolateHandle(Arc<IsolateAnnex>); pub struct IsolateHandle(Arc<IsolateAnnex>);
unsafe impl Send for IsolateHandle {}
unsafe impl Sync for IsolateHandle {}
impl IsolateHandle { impl IsolateHandle {
// This function is marked unsafe because it must be called only with either // This function is marked unsafe because it must be called only with either
// IsolateAnnex::mutex locked, or from the main thread associated with the V8 // IsolateAnnex::mutex locked, or from the main thread associated with the V8

View file

@ -86,7 +86,6 @@ pub mod script_compiler;
pub mod V8; pub mod V8;
pub use array_buffer::*; pub use array_buffer::*;
pub use bigint::*;
pub use data::*; pub use data::*;
pub use exception::*; pub use exception::*;
pub use external_references::ExternalReference; pub use external_references::ExternalReference;
@ -124,13 +123,11 @@ pub use platform::new_single_threaded_default_platform;
pub use platform::new_unprotected_default_platform; pub use platform::new_unprotected_default_platform;
pub use platform::Platform; pub use platform::Platform;
pub use primitives::*; pub use primitives::*;
pub use private::*;
pub use promise::{PromiseRejectEvent, PromiseRejectMessage, PromiseState}; pub use promise::{PromiseRejectEvent, PromiseRejectMessage, PromiseState};
pub use property_attribute::*; pub use property_attribute::*;
pub use property_descriptor::*; pub use property_descriptor::*;
pub use property_filter::*; pub use property_filter::*;
pub use property_handler_flags::*; pub use property_handler_flags::*;
pub use proxy::*;
pub use scope::AllowJavascriptExecutionScope; pub use scope::AllowJavascriptExecutionScope;
pub use scope::CallbackScope; pub use scope::CallbackScope;
pub use scope::ContextScope; pub use scope::ContextScope;
@ -150,7 +147,6 @@ pub use support::SharedPtr;
pub use support::SharedRef; pub use support::SharedRef;
pub use support::UniquePtr; pub use support::UniquePtr;
pub use support::UniqueRef; pub use support::UniqueRef;
pub use symbol::*;
pub use template::*; pub use template::*;
pub use value_deserializer::ValueDeserializer; pub use value_deserializer::ValueDeserializer;
pub use value_deserializer::ValueDeserializerHelper; pub use value_deserializer::ValueDeserializerHelper;

View file

@ -287,12 +287,11 @@ impl<'s> HandleScope<'s> {
for<'l> Local<'l, Data>: TryInto<Local<'l, T>>, for<'l> Local<'l, Data>: TryInto<Local<'l, T>>,
{ {
unsafe { unsafe {
let Some(res) = self let Some(res) = self.cast_local(|sd| {
.cast_local(|sd| { raw::v8__Isolate__GetDataFromSnapshotOnce(sd.get_isolate_ptr(), index)
raw::v8__Isolate__GetDataFromSnapshotOnce(sd.get_isolate_ptr(), index) }) else {
}) else { return Err(DataError::no_data::<T>());
return Err(DataError::no_data::<T>()); };
};
use get_data_sealed::ToDataError; use get_data_sealed::ToDataError;
match res.try_into() { match res.try_into() {
Ok(x) => Ok(x), Ok(x) => Ok(x),
@ -319,12 +318,14 @@ impl<'s> HandleScope<'s> {
for<'l> Local<'l, Data>: TryInto<Local<'l, T>>, for<'l> Local<'l, Data>: TryInto<Local<'l, T>>,
{ {
unsafe { unsafe {
let Some(res) = self let Some(res) = self.cast_local(|sd| {
.cast_local(|sd| { raw::v8__Context__GetDataFromSnapshotOnce(
raw::v8__Context__GetDataFromSnapshotOnce(sd.get_current_context(), index) sd.get_current_context(),
}) else { index,
return Err(DataError::no_data::<T>()); )
}; }) else {
return Err(DataError::no_data::<T>());
};
use get_data_sealed::ToDataError; use get_data_sealed::ToDataError;
match res.try_into() { match res.try_into() {
Ok(x) => Ok(x), Ok(x) => Ok(x),

View file

@ -66,9 +66,9 @@ impl Drop for StartupData {
impl Deref for StartupData { impl Deref for StartupData {
type Target = [u8]; type Target = [u8];
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
let data = self.data as *const u8; let data = self.data;
let len = usize::try_from(self.raw_size).unwrap(); let len = usize::try_from(self.raw_size).unwrap();
unsafe { std::slice::from_raw_parts(data, len) } unsafe { std::slice::from_raw_parts(data as _, len) }
} }
} }

View file

@ -514,7 +514,7 @@ impl<F> Copy for FieldOffset<F> {}
impl<F> Clone for FieldOffset<F> { impl<F> Clone for FieldOffset<F> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self(self.0, self.1) *self
} }
} }

View file

@ -17,7 +17,6 @@ impl UnboundModuleScript {
let code_cache = unsafe { let code_cache = unsafe {
UniqueRef::try_from_raw(v8__UnboundModuleScript__CreateCodeCache(self)) UniqueRef::try_from_raw(v8__UnboundModuleScript__CreateCodeCache(self))
}; };
#[cfg(debug_assertions)]
if let Some(code_cache) = &code_cache { if let Some(code_cache) = &code_cache {
debug_assert_eq!( debug_assert_eq!(
code_cache.buffer_policy(), code_cache.buffer_policy(),

View file

@ -34,7 +34,6 @@ impl UnboundScript {
let code_cache = unsafe { let code_cache = unsafe {
UniqueRef::try_from_raw(v8__UnboundScript__CreateCodeCache(self)) UniqueRef::try_from_raw(v8__UnboundScript__CreateCodeCache(self))
}; };
#[cfg(debug_assertions)]
if let Some(code_cache) = &code_cache { if let Some(code_cache) = &code_cache {
debug_assert_eq!( debug_assert_eq!(
code_cache.buffer_policy(), code_cache.buffer_policy(),

View file

@ -488,11 +488,7 @@ impl<'a, 's> ValueSerializer<'a, 's> {
&mut ptr, &mut ptr,
&mut size, &mut size,
); );
Vec::from_raw_parts( Vec::from_raw_parts(ptr, size, self.value_serializer_heap.buffer_size)
ptr as *mut u8,
size,
self.value_serializer_heap.buffer_size,
)
} }
} }

View file

@ -159,7 +159,7 @@ impl CompiledWasmModule {
let mut len = 0; let mut len = 0;
unsafe { unsafe {
let ptr = v8__CompiledWasmModule__SourceUrl(self.0, &mut len); let ptr = v8__CompiledWasmModule__SourceUrl(self.0, &mut len);
let bytes = std::slice::from_raw_parts(ptr as *const u8, len); let bytes = std::slice::from_raw_parts(ptr as _, len);
std::str::from_utf8_unchecked(bytes) std::str::from_utf8_unchecked(bytes)
} }
} }

View file

@ -1,24 +1,24 @@
error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandleScope<'_, '_>` is not satisfied error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandleScope<'_, '_>` is not satisfied
--> tests/compile_fail/handle_scope_escape_to_nowhere.rs:5:50 --> tests/compile_fail/handle_scope_escape_to_nowhere.rs:5:50
| |
5 | let mut _scope = v8::EscapableHandleScope::new(&mut isolate); 5 | let mut _scope = v8::EscapableHandleScope::new(&mut isolate);
| ----------------------------- ^^^^^^^^^^^^ the trait `v8::scope::param::NewEscapableHandleScope<'_, '_>` is not implemented for `OwnedIsolate` | ----------------------------- ^^^^^^^^^^^^ the trait `v8::scope::param::NewEscapableHandleScope<'_, '_>` is not implemented for `OwnedIsolate`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
= help: the following other types implement trait `v8::scope::param::NewEscapableHandleScope<'s, 'e>`: = help: the following other types implement trait `v8::scope::param::NewEscapableHandleScope<'s, 'e>`:
<AllowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>> <ContextScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<CallbackScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>> <HandleScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<ContextScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>> <EscapableHandleScope<'p, 'e, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<DisallowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>> <TryCatch<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<EscapableHandleScope<'p, 'e, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>> <CallbackScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<HandleScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>> <DisallowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<TryCatch<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>> <AllowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
note: required by a bound in `EscapableHandleScope::<'s, 'e>::new` note: required by a bound in `EscapableHandleScope::<'s, 'e>::new`
--> src/scope.rs --> src/scope.rs
| |
| pub fn new<P: param::NewEscapableHandleScope<'s, 'e>>( | pub fn new<P: param::NewEscapableHandleScope<'s, 'e>>(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EscapableHandleScope::<'s, 'e>::new` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EscapableHandleScope::<'s, 'e>::new`
error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandleScope<'_, '_>` is not satisfied error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandleScope<'_, '_>` is not satisfied
--> tests/compile_fail/handle_scope_escape_to_nowhere.rs:5:20 --> tests/compile_fail/handle_scope_escape_to_nowhere.rs:5:20
@ -27,13 +27,13 @@ error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandl
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `v8::scope::param::NewEscapableHandleScope<'_, '_>` is not implemented for `OwnedIsolate` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `v8::scope::param::NewEscapableHandleScope<'_, '_>` is not implemented for `OwnedIsolate`
| |
= help: the following other types implement trait `v8::scope::param::NewEscapableHandleScope<'s, 'e>`: = help: the following other types implement trait `v8::scope::param::NewEscapableHandleScope<'s, 'e>`:
<AllowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<CallbackScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<ContextScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>> <ContextScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<DisallowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<EscapableHandleScope<'p, 'e, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<HandleScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>> <HandleScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<EscapableHandleScope<'p, 'e, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<TryCatch<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>> <TryCatch<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<CallbackScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<DisallowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<AllowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandleScope<'_, '_>` is not satisfied error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandleScope<'_, '_>` is not satisfied
--> tests/compile_fail/handle_scope_escape_to_nowhere.rs:5:20 --> tests/compile_fail/handle_scope_escape_to_nowhere.rs:5:20
@ -42,10 +42,10 @@ error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandl
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `v8::scope::param::NewEscapableHandleScope<'_, '_>` is not implemented for `OwnedIsolate` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `v8::scope::param::NewEscapableHandleScope<'_, '_>` is not implemented for `OwnedIsolate`
| |
= help: the following other types implement trait `v8::scope::param::NewEscapableHandleScope<'s, 'e>`: = help: the following other types implement trait `v8::scope::param::NewEscapableHandleScope<'s, 'e>`:
<AllowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<CallbackScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<ContextScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>> <ContextScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<DisallowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<EscapableHandleScope<'p, 'e, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<HandleScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>> <HandleScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<EscapableHandleScope<'p, 'e, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<TryCatch<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>> <TryCatch<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<CallbackScope<'p, C> as v8::scope::param::NewEscapableHandleScope<'s, 'p>>
<DisallowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>
<AllowJavascriptExecutionScope<'p, P> as v8::scope::param::NewEscapableHandleScope<'s, 'e>>

View file

@ -1,15 +1,15 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> tests/compile_fail/object_without_context_scope.rs:6:33 --> tests/compile_fail/object_without_context_scope.rs:6:33
| |
6 | let _object = v8::Object::new(&mut scope); 6 | let _object = v8::Object::new(&mut scope);
| --------------- ^^^^^^^^^^ expected `&mut HandleScope<'_>`, found `&mut HandleScope<'_, ()>` | --------------- ^^^^^^^^^^ expected `&mut HandleScope<'_>`, found `&mut HandleScope<'_, ()>`
| | | |
| arguments to this function are incorrect | arguments to this function are incorrect
| |
= note: expected mutable reference `&mut HandleScope<'_>` = note: expected mutable reference `&mut HandleScope<'_, v8::Context>`
found mutable reference `&mut HandleScope<'_, ()>` found mutable reference `&mut HandleScope<'_, ()>`
note: associated function defined here note: associated function defined here
--> src/object.rs --> src/object.rs
| |
| pub fn new<'s>(scope: &mut HandleScope<'s>) -> Local<'s, Object> { | pub fn new<'s>(scope: &mut HandleScope<'s>) -> Local<'s, Object> {
| ^^^ | ^^^

View file

@ -263,8 +263,7 @@ fn test_string() {
assert_eq!(15, local.length()); assert_eq!(15, local.length());
assert_eq!(17, local.utf8_length(scope)); assert_eq!(17, local.utf8_length(scope));
assert_eq!(reference, local.to_rust_string_lossy(scope)); assert_eq!(reference, local.to_rust_string_lossy(scope));
let mut vec = Vec::new(); let mut vec = vec![0; 17];
vec.resize(17, 0);
let options = v8::WriteOptions::NO_NULL_TERMINATION; let options = v8::WriteOptions::NO_NULL_TERMINATION;
let mut nchars = 0; let mut nchars = 0;
assert_eq!( assert_eq!(
@ -705,8 +704,8 @@ fn get_isolate_from_handle() {
let context = v8::Context::new(scope); let context = v8::Context::new(scope);
let scope = &mut v8::ContextScope::new(scope, context); let scope = &mut v8::ContextScope::new(scope, context);
check_handle(scope, None, |s| v8::null(s)); check_handle(scope, None, v8::null);
check_handle(scope, None, |s| v8::undefined(s)); check_handle(scope, None, v8::undefined);
check_handle(scope, None, |s| v8::Boolean::new(s, true)); check_handle(scope, None, |s| v8::Boolean::new(s, true));
check_handle(scope, None, |s| v8::Boolean::new(s, false)); check_handle(scope, None, |s| v8::Boolean::new(s, false));
check_handle(scope, None, |s| v8::String::new(s, "").unwrap()); check_handle(scope, None, |s| v8::String::new(s, "").unwrap());
@ -878,13 +877,13 @@ fn array_buffer() {
data[0] = 1; data[0] = 1;
let unique_bs = let unique_bs =
v8::ArrayBuffer::new_backing_store_from_bytes(Box::new(data)); v8::ArrayBuffer::new_backing_store_from_bytes(Box::new(data));
assert_eq!(unique_bs.get(0).unwrap().get(), 1); assert_eq!(unique_bs.first().unwrap().get(), 1);
assert_eq!(unique_bs.get(15).unwrap().get(), 100); assert_eq!(unique_bs.get(15).unwrap().get(), 100);
let ab = let ab =
v8::ArrayBuffer::with_backing_store(scope, &unique_bs.make_shared()); v8::ArrayBuffer::with_backing_store(scope, &unique_bs.make_shared());
assert_eq!(ab.byte_length(), 16); assert_eq!(ab.byte_length(), 16);
assert_eq!(ab.get_backing_store().get(0).unwrap().get(), 1); assert_eq!(ab.get_backing_store().first().unwrap().get(), 1);
} }
} }
@ -1001,7 +1000,7 @@ fn deref_empty_backing_store() {
let backing_store = v8::ArrayBuffer::new_backing_store(isolate, 0); let backing_store = v8::ArrayBuffer::new_backing_store(isolate, 0);
let slice: &[std::cell::Cell<u8>] = &backing_store; let slice: &[std::cell::Cell<u8>] = &backing_store;
assert!(!slice.as_ptr().is_null()); assert!(!std::hint::black_box(slice.as_ptr()).is_null());
} }
fn eval<'s>( fn eval<'s>(
@ -4203,6 +4202,7 @@ fn promise_reject_callback_no_value() {
} }
#[test] #[test]
#[allow(clippy::clone_on_copy)]
fn promise_hook() { fn promise_hook() {
extern "C" fn hook( extern "C" fn hook(
type_: v8::PromiseHookType, type_: v8::PromiseHookType,
@ -4210,8 +4210,8 @@ fn promise_hook() {
_parent: v8::Local<v8::Value>, _parent: v8::Local<v8::Value>,
) { ) {
// Check that PromiseHookType implements Clone and PartialEq. // Check that PromiseHookType implements Clone and PartialEq.
#[allow(clippy::clone_on_copy)] _ = type_.clone() == v8::PromiseHookType::Init;
if type_.clone() == v8::PromiseHookType::Init {}
let scope = &mut unsafe { v8::CallbackScope::new(promise) }; let scope = &mut unsafe { v8::CallbackScope::new(promise) };
let context = promise.get_creation_context(scope).unwrap(); let context = promise.get_creation_context(scope).unwrap();
let scope = &mut v8::ContextScope::new(scope, context); let scope = &mut v8::ContextScope::new(scope, context);
@ -5468,8 +5468,8 @@ fn snapshot_creator_multiple_contexts() {
fn external_references() { fn external_references() {
let _setup_guard = setup::sequential_test(); let _setup_guard = setup::sequential_test();
// Allocate externals for the test. // Allocate externals for the test.
let external_ptr = Box::into_raw(vec![0_u8, 1, 2, 3, 4].into_boxed_slice()) let external_ptr =
as *mut [u8] as *mut c_void; Box::into_raw(vec![0_u8, 1, 2, 3, 4].into_boxed_slice()) as *mut c_void;
// Push them to the external reference table. // Push them to the external reference table.
let refs = [ let refs = [
v8::ExternalReference { v8::ExternalReference {
@ -7683,16 +7683,13 @@ fn bigint() {
let raw_b = v8::Local::<v8::BigInt>::try_from(raw_b).unwrap(); let raw_b = v8::Local::<v8::BigInt>::try_from(raw_b).unwrap();
let mut vec = Vec::new(); let mut vec = vec![0; raw_b.word_count()];
vec.resize(raw_b.word_count(), 0);
assert_eq!(raw_b.to_words_array(&mut vec), (true, &mut [10, 10][..])); assert_eq!(raw_b.to_words_array(&mut vec), (true, &mut [10, 10][..]));
let mut vec = Vec::new(); let mut vec = vec![0; 1];
vec.resize(1, 0);
assert_eq!(raw_b.to_words_array(&mut vec), (true, &mut [10][..])); assert_eq!(raw_b.to_words_array(&mut vec), (true, &mut [10][..]));
let mut vec = Vec::new(); let mut vec = vec![1337, 20];
vec.resize(20, 1337);
assert_eq!(raw_b.to_words_array(&mut vec), (true, &mut [10, 10][..])); assert_eq!(raw_b.to_words_array(&mut vec), (true, &mut [10, 10][..]));
} }
@ -8415,7 +8412,7 @@ fn run_with_rust_allocator() {
unsafe extern "C" fn allocate(count: &AtomicUsize, n: usize) -> *mut c_void { unsafe extern "C" fn allocate(count: &AtomicUsize, n: usize) -> *mut c_void {
count.fetch_add(n, Ordering::SeqCst); count.fetch_add(n, Ordering::SeqCst);
Box::into_raw(vec![0u8; n].into_boxed_slice()) as *mut [u8] as *mut c_void Box::into_raw(vec![0u8; n].into_boxed_slice()) as *mut c_void
} }
unsafe extern "C" fn allocate_uninitialized( unsafe extern "C" fn allocate_uninitialized(
count: &AtomicUsize, count: &AtomicUsize,
@ -8443,7 +8440,7 @@ fn run_with_rust_allocator() {
let copy_len = oldlen.min(newlen); let copy_len = oldlen.min(newlen);
new_store.extend_from_slice(&old_store[..copy_len]); new_store.extend_from_slice(&old_store[..copy_len]);
new_store.resize(newlen, 0u8); new_store.resize(newlen, 0u8);
Box::into_raw(new_store.into_boxed_slice()) as *mut [u8] as *mut c_void Box::into_raw(new_store.into_boxed_slice()) as *mut c_void
} }
unsafe extern "C" fn drop(count: *const AtomicUsize) { unsafe extern "C" fn drop(count: *const AtomicUsize) {
Arc::from_raw(count); Arc::from_raw(count);