Skip to content

Commit

Permalink
Always allow dead_code/unused_import warnings in wasmtime
Browse files Browse the repository at this point in the history
Finishes the work started in bytecodealliance#10131 and this means that the crate is no
longer special and has the same default settings of all other crates in
all situations.
  • Loading branch information
alexcrichton committed Jan 30, 2025
1 parent e60b6e6 commit 24eb3ea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 0 additions & 6 deletions crates/wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,6 @@
#![doc(test(attr(deny(warnings))))]
#![doc(test(attr(allow(dead_code, unused_variables, unused_mut))))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// NB: this list is currently being burned down to remove all features listed
// here to get warnings in all configurations of Wasmtime.
#![cfg_attr(
any(not(feature = "runtime"), not(feature = "std")),
allow(dead_code, unused_imports)
)]
// Allow broken links when the default features is disabled because most of our
// documentation is written for the "one build" of the `main` branch which has
// most features enabled. This will present warnings in stripped-down doc builds
Expand Down
17 changes: 13 additions & 4 deletions crates/wasmtime/src/runtime/vm/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use super::HostAlignedByteCount;
use crate::prelude::*;
use crate::runtime::vm::sys::{mmap, vm::MemoryImageSource};
use alloc::sync::Arc;
use core::marker;
use core::ops::Range;
use core::ptr::NonNull;
#[cfg(feature = "std")]
Expand Down Expand Up @@ -58,7 +59,9 @@ pub struct UnalignedLength {
#[derive(Debug)]
pub struct Mmap<T> {
sys: mmap::Mmap,
#[cfg(feature = "std")]
data: T,
_marker: marker::PhantomData<T>,
}

impl Mmap<AlignedLength> {
Expand Down Expand Up @@ -86,19 +89,25 @@ impl Mmap<AlignedLength> {
if mapping_size.is_zero() {
Ok(Mmap {
sys: mmap::Mmap::new_empty(),
#[cfg(feature = "std")]
data: AlignedLength {},
_marker: marker::PhantomData,
})
} else if accessible_size == mapping_size {
Ok(Mmap {
sys: mmap::Mmap::new(mapping_size)
.context(format!("mmap failed to allocate {mapping_size:#x} bytes"))?,
#[cfg(feature = "std")]
data: AlignedLength {},
_marker: marker::PhantomData,
})
} else {
let result = Mmap {
sys: mmap::Mmap::reserve(mapping_size)
.context(format!("mmap failed to reserve {mapping_size:#x} bytes"))?,
#[cfg(feature = "std")]
data: AlignedLength {},
_marker: marker::PhantomData,
};
if !accessible_size.is_zero() {
// SAFETY: result was just created and is not in use.
Expand All @@ -121,10 +130,9 @@ impl Mmap<AlignedLength> {
pub fn into_unaligned(self) -> Mmap<UnalignedLength> {
Mmap {
sys: self.sys,
data: UnalignedLength {
#[cfg(feature = "std")]
file: None,
},
#[cfg(feature = "std")]
data: UnalignedLength { file: None },
_marker: marker::PhantomData,
}
}

Expand Down Expand Up @@ -207,6 +215,7 @@ impl Mmap<UnalignedLength> {
Ok(Mmap {
sys,
data: UnalignedLength { file: Some(file) },
_marker: marker::PhantomData,
})
}

Expand Down
3 changes: 1 addition & 2 deletions crates/wasmtime/src/runtime/vm/mmap_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ use crate::runtime::vm::send_sync_ptr::SendSyncPtr;
use crate::runtime::vm::{mmap::UnalignedLength, Mmap};
#[cfg(not(has_virtual_memory))]
use alloc::alloc::Layout;
use alloc::sync::Arc;
use core::ops::{Deref, Range};
#[cfg(not(has_virtual_memory))]
use core::ptr::NonNull;
#[cfg(feature = "std")]
use std::fs::File;
use std::{fs::File, sync::Arc};

/// A type which prefers to store backing memory in an OS-backed memory mapping
/// but can fall back to the regular memory allocator as well.
Expand Down

0 comments on commit 24eb3ea

Please sign in to comment.