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

Always allow dead_code/unused_import warnings in wasmtime #10158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 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
Loading