Don't be clever about representing non-CoW images (#4691)
This commit fixes a build warning on Rust 1.63 when the `memory-init-cow`
feature is disabled in the `wasmtime-runtime` crate. Some "tricks" were
used prior to have the `MemoryImage` type be an empty `enum {}` but that
wreaks havoc with warnings so this commit instead just makes it a unit
struct and makes all methods panic (as they shouldn't be hit anyway).
This commit is contained in:
@@ -35,7 +35,9 @@ impl ModuleMemoryImages {
|
|||||||
/// places (e.g. a `Memory`), we define a zero-sized type when memory is
|
/// places (e.g. a `Memory`), we define a zero-sized type when memory is
|
||||||
/// not included in the build.
|
/// not included in the build.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum MemoryImageSlot {}
|
pub struct MemoryImageSlot {
|
||||||
|
_priv: (),
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl MemoryImageSlot {
|
impl MemoryImageSlot {
|
||||||
@@ -48,26 +50,26 @@ impl MemoryImageSlot {
|
|||||||
_: usize,
|
_: usize,
|
||||||
_: Option<&Arc<MemoryImage>>,
|
_: Option<&Arc<MemoryImage>>,
|
||||||
) -> Result<Self, InstantiationError> {
|
) -> Result<Self, InstantiationError> {
|
||||||
match *self {}
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn no_clear_on_drop(&mut self) {
|
pub(crate) fn no_clear_on_drop(&mut self) {
|
||||||
match *self {}
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn clear_and_remain_ready(&mut self) -> Result<()> {
|
pub(crate) fn clear_and_remain_ready(&mut self) -> Result<()> {
|
||||||
match *self {}
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn has_image(&self) -> bool {
|
pub(crate) fn has_image(&self) -> bool {
|
||||||
match *self {}
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_dirty(&self) -> bool {
|
pub(crate) fn is_dirty(&self) -> bool {
|
||||||
match *self {}
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_heap_limit(&mut self, _: usize) -> Result<()> {
|
pub(crate) fn set_heap_limit(&mut self, _: usize) -> Result<()> {
|
||||||
match *self {}
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
clippy::use_self
|
clippy::use_self
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(memory_init_cow), allow(unused_variables, unreachable_code))]
|
|
||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
|
||||||
|
|||||||
Reference in New Issue
Block a user