Fix a compile error on nightly Rust (#4724)
It looks like Rust nightly has gotten a bit more strict about attributes-on-expressions and previously accepted code is no longer accepted. This commit updates the generated code for a macro to a form which is accepted by rustc.
This commit is contained in:
@@ -37,15 +37,20 @@ use wasmtime_runtime::{Export, ExportFunction, VMTrampoline};
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! map_maybe_uninit {
|
macro_rules! map_maybe_uninit {
|
||||||
($maybe_uninit:ident $($field:tt)*) => (#[allow(unused_unsafe)] unsafe {
|
($maybe_uninit:ident $($field:tt)*) => ({
|
||||||
use $crate::component::__internal::MaybeUninitExt;
|
#[allow(unused_unsafe)]
|
||||||
|
{
|
||||||
|
unsafe {
|
||||||
|
use $crate::component::__internal::MaybeUninitExt;
|
||||||
|
|
||||||
let m: &mut std::mem::MaybeUninit<_> = $maybe_uninit;
|
let m: &mut std::mem::MaybeUninit<_> = $maybe_uninit;
|
||||||
// Note the usage of `addr_of_mut!` here which is an attempt to "stay
|
// Note the usage of `addr_of_mut!` here which is an attempt to "stay
|
||||||
// safe" here where we never accidentally create `&mut T` where `T` is
|
// safe" here where we never accidentally create `&mut T` where `T` is
|
||||||
// actually uninitialized, hopefully appeasing the Rust unsafe
|
// actually uninitialized, hopefully appeasing the Rust unsafe
|
||||||
// guidelines gods.
|
// guidelines gods.
|
||||||
m.map(|p| std::ptr::addr_of_mut!((*p)$($field)*))
|
m.map(|p| std::ptr::addr_of_mut!((*p)$($field)*))
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user