Browse Source

Fix some warnings on nightly Rust (#6388)

Upstream rust has decided that ignoring a value is not spelled
`drop(foo)` but instead it's spelled `let _ = foo`
pull/6392/head
Alex Crichton 2 years ago
committed by GitHub
parent
commit
7f0228c967
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      cranelift/wasm/src/environ/spec.rs
  2. 3
      crates/environ/src/component/translate.rs
  3. 2
      crates/fiber/src/lib.rs
  4. 2
      crates/fuzzing/src/oracles.rs
  5. 2
      crates/fuzzing/src/oracles/diff_spec.rs
  6. 2
      crates/runtime/src/externref.rs
  7. 4
      crates/runtime/src/instance/allocator.rs
  8. 2
      crates/runtime/src/traphandlers/unix.rs
  9. 4
      crates/wasmtime/src/store.rs
  10. 2
      tests/all/async_functions.rs
  11. 10
      tests/all/func.rs
  12. 8
      tests/all/funcref.rs
  13. 1
      tests/all/globals.rs
  14. 10
      tests/all/host_funcs.rs
  15. 8
      tests/all/linker.rs
  16. 2
      tests/all/pooling_allocator.rs
  17. 2
      winch/codegen/src/visitor.rs

14
cranelift/wasm/src/environ/spec.rs

@ -101,7 +101,7 @@ pub trait FuncEnvironment: TargetEnvironment {
/// Called after the locals for a function have been parsed, and the number /// Called after the locals for a function have been parsed, and the number
/// of variables defined by this function is provided. /// of variables defined by this function is provided.
fn after_locals(&mut self, num_locals_defined: usize) { fn after_locals(&mut self, num_locals_defined: usize) {
drop(num_locals_defined); let _ = num_locals_defined;
} }
/// Set up the necessary preamble definitions in `func` to access the global variable /// Set up the necessary preamble definitions in `func` to access the global variable
@ -560,7 +560,7 @@ pub trait ModuleEnvironment<'data> {
/// Translates a type index to its signature index, only called for type /// Translates a type index to its signature index, only called for type
/// indices which point to functions. /// indices which point to functions.
fn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex> { fn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex> {
drop(index); let _ = index;
Err(WasmError::Unsupported("module linking".to_string())) Err(WasmError::Unsupported("module linking".to_string()))
} }
@ -601,7 +601,7 @@ pub trait ModuleEnvironment<'data> {
module: &'data str, module: &'data str,
field: &'data str, field: &'data str,
) -> WasmResult<()> { ) -> WasmResult<()> {
drop((tag, module, field)); let _ = (tag, module, field);
Err(WasmError::Unsupported("wasm tags".to_string())) Err(WasmError::Unsupported("wasm tags".to_string()))
} }
@ -653,7 +653,7 @@ pub trait ModuleEnvironment<'data> {
/// Declares an tag to the environment /// Declares an tag to the environment
fn declare_tag(&mut self, tag: Tag) -> WasmResult<()> { fn declare_tag(&mut self, tag: Tag) -> WasmResult<()> {
drop(tag); let _ = tag;
Err(WasmError::Unsupported("wasm tags".to_string())) Err(WasmError::Unsupported("wasm tags".to_string()))
} }
@ -688,7 +688,7 @@ pub trait ModuleEnvironment<'data> {
/// Declares an tag export to the environment. /// Declares an tag export to the environment.
fn declare_tag_export(&mut self, tag_index: TagIndex, name: &'data str) -> WasmResult<()> { fn declare_tag_export(&mut self, tag_index: TagIndex, name: &'data str) -> WasmResult<()> {
drop((tag_index, name)); let _ = (tag_index, name);
Err(WasmError::Unsupported("wasm tags".to_string())) Err(WasmError::Unsupported("wasm tags".to_string()))
} }
@ -732,7 +732,7 @@ pub trait ModuleEnvironment<'data> {
/// Indicates that a declarative element segment was seen in the wasm /// Indicates that a declarative element segment was seen in the wasm
/// module. /// module.
fn declare_elements(&mut self, elements: Box<[FuncIndex]>) -> WasmResult<()> { fn declare_elements(&mut self, elements: Box<[FuncIndex]>) -> WasmResult<()> {
drop(elements); let _ = elements;
Ok(()) Ok(())
} }
@ -751,7 +751,7 @@ pub trait ModuleEnvironment<'data> {
/// Indicates how many functions the code section reports and the byte /// Indicates how many functions the code section reports and the byte
/// offset of where the code sections starts. /// offset of where the code sections starts.
fn reserve_function_bodies(&mut self, bodies: u32, code_section_offset: u64) { fn reserve_function_bodies(&mut self, bodies: u32, code_section_offset: u64) {
drop((bodies, code_section_offset)); let _ = (bodies, code_section_offset);
} }
/// Provides the contents of a function body. /// Provides the contents of a function body.

3
crates/environ/src/component/translate.rs

@ -670,12 +670,11 @@ impl<'a, 'data> Translator<'a, 'data> {
for alias in s { for alias in s {
let init = match alias? { let init = match alias? {
wasmparser::ComponentAlias::InstanceExport { wasmparser::ComponentAlias::InstanceExport {
kind, kind: _,
instance_index, instance_index,
name, name,
} => { } => {
let instance = ComponentInstanceIndex::from_u32(instance_index); let instance = ComponentInstanceIndex::from_u32(instance_index);
drop(kind);
self.alias_component_instance_export(instance, name); self.alias_component_instance_export(instance, name);
LocalInitializer::AliasComponentExport(instance, name) LocalInitializer::AliasComponentExport(instance, name)
} }

2
crates/fiber/src/lib.rs

@ -263,7 +263,7 @@ mod tests {
let b = SetOnDrop(a.clone()); let b = SetOnDrop(a.clone());
let fiber = let fiber =
Fiber::<(), (), ()>::new(FiberStack::new(1024 * 1024).unwrap(), move |(), _s| { Fiber::<(), (), ()>::new(FiberStack::new(1024 * 1024).unwrap(), move |(), _s| {
drop(&b); let _ = &b;
panic!(); panic!();
}) })
.unwrap(); .unwrap();

2
crates/fuzzing/src/oracles.rs

@ -508,7 +508,7 @@ pub fn make_api_calls(api: generators::api::ApiCalls) {
ApiCall::InstanceDrop { id } => { ApiCall::InstanceDrop { id } => {
log::trace!("dropping instance {}", id); log::trace!("dropping instance {}", id);
drop(instances.remove(&id)); instances.remove(&id);
} }
ApiCall::CallExportedFunc { instance, nth } => { ApiCall::CallExportedFunc { instance, nth } => {

2
crates/fuzzing/src/oracles/diff_spec.rs

@ -41,7 +41,7 @@ impl DiffEngine for SpecInterpreter {
fn assert_error_match(&self, trap: &Trap, err: &Error) { fn assert_error_match(&self, trap: &Trap, err: &Error) {
// TODO: implement this for the spec interpreter // TODO: implement this for the spec interpreter
drop((trap, err)); let _ = (trap, err);
} }
fn is_stack_overflow(&self, err: &Error) -> bool { fn is_stack_overflow(&self, err: &Error) -> bool {

2
crates/runtime/src/externref.rs

@ -219,8 +219,6 @@ impl Drop for VMExternRef {
} }
atomic::fence(Ordering::Acquire); atomic::fence(Ordering::Acquire);
// Drop our live reference to `data` before we drop it itself.
drop(data);
unsafe { unsafe {
VMExternData::drop_and_dealloc(self.0); VMExternData::drop_and_dealloc(self.0);
} }

4
crates/runtime/src/instance/allocator.rs

@ -90,7 +90,7 @@ impl StorePtr {
pub unsafe trait InstanceAllocator { pub unsafe trait InstanceAllocator {
/// Validates that a module is supported by the allocator. /// Validates that a module is supported by the allocator.
fn validate(&self, module: &Module, offsets: &VMOffsets<HostPtr>) -> Result<()> { fn validate(&self, module: &Module, offsets: &VMOffsets<HostPtr>) -> Result<()> {
drop((module, offsets)); let _ = (module, offsets);
Ok(()) Ok(())
} }
@ -419,7 +419,7 @@ pub struct OnDemandInstanceAllocator {
impl OnDemandInstanceAllocator { impl OnDemandInstanceAllocator {
/// Creates a new on-demand instance allocator. /// Creates a new on-demand instance allocator.
pub fn new(mem_creator: Option<Arc<dyn RuntimeMemoryCreator>>, stack_size: usize) -> Self { pub fn new(mem_creator: Option<Arc<dyn RuntimeMemoryCreator>>, stack_size: usize) -> Self {
drop(stack_size); // suppress unused warnings w/o async feature let _ = stack_size; // suppress unused warnings w/o async feature
Self { Self {
mem_creator, mem_creator,
#[cfg(feature = "async")] #[cfg(feature = "async")]

2
crates/runtime/src/traphandlers/unix.rs

@ -251,7 +251,7 @@ unsafe fn get_pc_and_fp(cx: *mut libc::c_void, _signum: libc::c_int) -> (*const
unsafe fn set_pc(cx: *mut libc::c_void, pc: usize, arg1: usize) { unsafe fn set_pc(cx: *mut libc::c_void, pc: usize, arg1: usize) {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(not(target_os = "macos"))] { if #[cfg(not(target_os = "macos"))] {
drop((cx, pc, arg1)); let _ = (cx, pc, arg1);
unreachable!(); // not used on these platforms unreachable!(); // not used on these platforms
} else if #[cfg(target_arch = "x86_64")] { } else if #[cfg(target_arch = "x86_64")] {
let cx = &mut *(cx as *mut libc::ucontext_t); let cx = &mut *(cx as *mut libc::ucontext_t);

4
crates/wasmtime/src/store.rs

@ -356,7 +356,7 @@ where
T: std::ops::DerefMut<Target = StoreOpaque>, T: std::ops::DerefMut<Target = StoreOpaque>,
{ {
pub fn new(mut store: T) -> Self { pub fn new(mut store: T) -> Self {
drop(&mut store); let _ = &mut store;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
{ {
let prev_okay = store.externref_activations_table.set_gc_okay(false); let prev_okay = store.externref_activations_table.set_gc_okay(false);
@ -1979,7 +1979,7 @@ impl<T> StoreInner<T> {
{ {
self.epoch_deadline_behavior = EpochDeadline::YieldAndExtendDeadline { delta }; self.epoch_deadline_behavior = EpochDeadline::YieldAndExtendDeadline { delta };
} }
drop(delta); // suppress warning in non-async build let _ = delta; // suppress warning in non-async build
} }
fn get_epoch_deadline(&self) -> u64 { fn get_epoch_deadline(&self) -> u64 {

2
tests/all/async_functions.rs

@ -275,7 +275,7 @@ async fn cancel_during_run() {
// SetOnDrop is not destroyed when dropping the reference of it // SetOnDrop is not destroyed when dropping the reference of it
// here. Instead, it is moved into the future where it's forced // here. Instead, it is moved into the future where it's forced
// to live in and will be destroyed at the end of the future. // to live in and will be destroyed at the end of the future.
drop(&dtor); let _ = &dtor;
tokio::task::yield_now().await; tokio::task::yield_now().await;
Ok(()) Ok(())
}) })

10
tests/all/func.rs

@ -416,7 +416,7 @@ fn dtor_runs() {
let a = A; let a = A;
assert_eq!(HITS.load(SeqCst), 0); assert_eq!(HITS.load(SeqCst), 0);
Func::wrap(&mut store, move || { Func::wrap(&mut store, move || {
drop(&a); let _ = &a;
}); });
drop(store); drop(store);
assert_eq!(HITS.load(SeqCst), 1); assert_eq!(HITS.load(SeqCst), 1);
@ -436,7 +436,9 @@ fn dtor_delayed() -> Result<()> {
let mut store = Store::<()>::default(); let mut store = Store::<()>::default();
let a = A; let a = A;
let func = Func::wrap(&mut store, move || drop(&a)); let func = Func::wrap(&mut store, move || {
let _ = &a;
});
assert_eq!(HITS.load(SeqCst), 0); assert_eq!(HITS.load(SeqCst), 0);
let wasm = wat::parse_str(r#"(import "" "" (func))"#)?; let wasm = wat::parse_str(r#"(import "" "" (func))"#)?;
@ -993,7 +995,7 @@ fn trap_doesnt_leak() -> anyhow::Result<()> {
let canary1 = Canary::default(); let canary1 = Canary::default();
let dtor1_run = canary1.0.clone(); let dtor1_run = canary1.0.clone();
let f1 = Func::wrap(&mut store, move || -> Result<()> { let f1 = Func::wrap(&mut store, move || -> Result<()> {
drop(&canary1); let _ = &canary1;
bail!("") bail!("")
}); });
assert!(f1.typed::<(), ()>(&store)?.call(&mut store, ()).is_err()); assert!(f1.typed::<(), ()>(&store)?.call(&mut store, ()).is_err());
@ -1003,7 +1005,7 @@ fn trap_doesnt_leak() -> anyhow::Result<()> {
let canary2 = Canary::default(); let canary2 = Canary::default();
let dtor2_run = canary2.0.clone(); let dtor2_run = canary2.0.clone();
let f2 = Func::new(&mut store, FuncType::new(None, None), move |_, _, _| { let f2 = Func::new(&mut store, FuncType::new(None, None), move |_, _, _| {
drop(&canary2); let _ = &canary2;
bail!("") bail!("")
}); });
assert!(f2.typed::<(), ()>(&store)?.call(&mut store, ()).is_err()); assert!(f2.typed::<(), ()>(&store)?.call(&mut store, ()).is_err());

8
tests/all/funcref.rs

@ -110,7 +110,9 @@ fn wrong_store() -> anyhow::Result<()> {
let mut store2 = Store::<()>::default(); let mut store2 = Store::<()>::default();
let set = SetOnDrop(dropped.clone()); let set = SetOnDrop(dropped.clone());
let f1 = Func::wrap(&mut store1, move || drop(&set)); let f1 = Func::wrap(&mut store1, move || {
let _ = &set;
});
let f2 = Func::wrap(&mut store2, move || Some(f1.clone())); let f2 = Func::wrap(&mut store2, move || Some(f1.clone()));
assert!(f2.call(&mut store2, &[], &mut []).is_err()); assert!(f2.call(&mut store2, &[], &mut []).is_err());
} }
@ -136,7 +138,9 @@ fn func_new_returns_wrong_store() -> anyhow::Result<()> {
let mut store2 = Store::<()>::default(); let mut store2 = Store::<()>::default();
let set = SetOnDrop(dropped.clone()); let set = SetOnDrop(dropped.clone());
let f1 = Func::wrap(&mut store1, move || drop(&set)); let f1 = Func::wrap(&mut store1, move || {
let _ = &set;
});
let f2 = Func::new( let f2 = Func::new(
&mut store2, &mut store2,
FuncType::new(None, Some(ValType::FuncRef)), FuncType::new(None, Some(ValType::FuncRef)),

1
tests/all/globals.rs

@ -73,7 +73,6 @@ fn use_after_drop() -> anyhow::Result<()> {
let g = instance.get_global(&mut store, "foo").unwrap(); let g = instance.get_global(&mut store, "foo").unwrap();
assert_eq!(g.get(&mut store).i32(), Some(100)); assert_eq!(g.get(&mut store).i32(), Some(100));
g.set(&mut store, 101.into())?; g.set(&mut store, 101.into())?;
drop(instance);
assert_eq!(g.get(&mut store).i32(), Some(101)); assert_eq!(g.get(&mut store).i32(), Some(101));
Instance::new(&mut store, &module, &[])?; Instance::new(&mut store, &module, &[])?;
assert_eq!(g.get(&mut store).i32(), Some(101)); assert_eq!(g.get(&mut store).i32(), Some(101));

10
tests/all/host_funcs.rs

@ -61,7 +61,7 @@ fn drop_func() -> Result<()> {
let a = A; let a = A;
linker.func_wrap("", "", move || { linker.func_wrap("", "", move || {
drop(&a); let _ = &a;
})?; })?;
assert_eq!(HITS.load(SeqCst), 0); assert_eq!(HITS.load(SeqCst), 0);
@ -70,7 +70,7 @@ fn drop_func() -> Result<()> {
let a = A; let a = A;
linker.func_wrap("", "", move || { linker.func_wrap("", "", move || {
drop(&a); let _ = &a;
})?; })?;
assert_eq!(HITS.load(SeqCst), 1); assert_eq!(HITS.load(SeqCst), 1);
@ -98,7 +98,9 @@ fn drop_delayed() -> Result<()> {
let mut linker = Linker::<()>::new(&engine); let mut linker = Linker::<()>::new(&engine);
let a = A; let a = A;
linker.func_wrap("", "", move || drop(&a))?; linker.func_wrap("", "", move || {
let _ = &a;
})?;
assert_eq!(HITS.load(SeqCst), 0); assert_eq!(HITS.load(SeqCst), 0);
@ -642,7 +644,7 @@ fn call_via_funcref() -> Result<()> {
let mut linker = Linker::new(&engine); let mut linker = Linker::new(&engine);
let a = A; let a = A;
linker.func_wrap("", "", move |x: i32, y: i32| { linker.func_wrap("", "", move |x: i32, y: i32| {
drop(&a); let _ = &a;
x + y x + y
})?; })?;

8
tests/all/linker.rs

@ -251,7 +251,9 @@ fn no_leak_with_imports() -> Result<()> {
let mut store = Store::new(&Engine::default(), DropMe(flag.clone())); let mut store = Store::new(&Engine::default(), DropMe(flag.clone()));
let mut linker = Linker::new(store.engine()); let mut linker = Linker::new(store.engine());
let drop_me = DropMe(flag.clone()); let drop_me = DropMe(flag.clone());
linker.func_wrap("", "", move || drop(&drop_me))?; linker.func_wrap("", "", move || {
let _ = &drop_me;
})?;
let module = Module::new( let module = Module::new(
store.engine(), store.engine(),
r#" r#"
@ -296,7 +298,9 @@ fn funcs_live_on_to_fight_another_day() -> Result<()> {
let engine = Engine::default(); let engine = Engine::default();
let mut linker = Linker::new(&engine); let mut linker = Linker::new(&engine);
let drop_me = DropMe(flag.clone()); let drop_me = DropMe(flag.clone());
linker.func_wrap("", "", move || drop(&drop_me))?; linker.func_wrap("", "", move || {
let _ = &drop_me;
})?;
assert_eq!(flag.load(SeqCst), 0); assert_eq!(flag.load(SeqCst), 0);
let get_and_call = || -> Result<()> { let get_and_call = || -> Result<()> {

2
tests/all/pooling_allocator.rs

@ -587,7 +587,7 @@ fn drop_externref_global_during_module_init() -> Result<()> {
)?; )?;
let mut store = Store::new(&engine, Limiter); let mut store = Store::new(&engine, Limiter);
drop(Instance::new(&mut store, &module, &[])?); Instance::new(&mut store, &module, &[])?;
drop(store); drop(store);
let module = Module::new( let module = Module::new(

2
winch/codegen/src/visitor.rs

@ -26,7 +26,7 @@ macro_rules! def_unsupported {
$op $op
fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output { fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output {
$($(drop($arg);)*)? $($(let _ = $arg;)*)?
todo!(stringify!($op)) todo!(stringify!($op))
} }
); );

Loading…
Cancel
Save