Fixes for newer clippy
continuous-integration/drone Build is passing Details

This commit is contained in:
Deukhoofd 2023-09-24 18:24:02 +02:00
parent d8b8559c2e
commit e666bb5a0e
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
11 changed files with 22 additions and 53 deletions

View File

@ -253,7 +253,7 @@ impl Battle {
data.target_side(), data.target_side(),
data.target_index(), data.target_index(),
data.used_move().move_data().target(), data.used_move().move_data().target(),
choice.user().deref(), choice.user(),
) { ) {
return false; return false;
} }

View File

@ -233,3 +233,7 @@ impl ScriptSource for ExecutingMove {
Ok(()) Ok(())
} }
} }
unsafe impl Send for ExecutingMove {}
unsafe impl Sync for ExecutingMove {}

View File

@ -137,9 +137,9 @@ pub struct WeakPokemonReference {
data: Weak<PokemonData>, data: Weak<PokemonData>,
} }
unsafe impl Send for WeakPokemonReference {} unsafe impl Send for PokemonData {}
unsafe impl Sync for WeakPokemonReference {} unsafe impl Sync for PokemonData {}
impl Pokemon { impl Pokemon {
/// Instantiates a new Pokemon. /// Instantiates a new Pokemon.

View File

@ -104,9 +104,9 @@ impl Into<anyhow_ext::Result<SerializedPokemon>> for &Pokemon {
weight: self.weight(), weight: self.weight(),
height: self.height(), height: self.height(),
happiness: self.happiness(), happiness: self.happiness(),
stat_boosts: self.stat_boosts().deref().deref().clone(), stat_boosts: self.stat_boosts().deref().clone(),
individual_values: self.individual_values().deref().deref().clone(), individual_values: self.individual_values().deref().clone(),
effort_values: self.effort_values().deref().deref().clone(), effort_values: self.effort_values().deref().clone(),
nature: self.library().static_data().natures().get_nature_name(self.nature())?, nature: self.library().static_data().natures().get_nature_name(self.nature())?,
nickname: self.nickname().clone(), nickname: self.nickname().clone(),
ability_index: *self.real_ability(), ability_index: *self.real_ability(),

View File

@ -36,10 +36,7 @@ pub(super) struct FFIHandle<T> {
impl<T> Clone for FFIHandle<T> { impl<T> Clone for FFIHandle<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { *self
handle: self.handle,
_marker: std::marker::PhantomData,
}
} }
} }

View File

@ -5,7 +5,7 @@ mod ffi_handle;
/// The foreign function interfaces for that static data /// The foreign function interfaces for that static data
mod static_data; mod static_data;
pub(self) use ffi_handle::*; use ffi_handle::*;
/// Helper type for clearer functions. /// Helper type for clearer functions.
#[repr(transparent)] #[repr(transparent)]
@ -86,15 +86,15 @@ macro_rules! ffi_handle_vec_stringkey_getters {
}; };
} }
pub(self) use ffi_handle_arc_dyn_getter; use ffi_handle_arc_dyn_getter;
pub(self) use ffi_handle_arc_stringkey_getter; use ffi_handle_arc_stringkey_getter;
pub(self) use ffi_handle_vec_stringkey_getters; use ffi_handle_vec_stringkey_getters;
pub(self) use ffi_handle_vec_value_getters; use ffi_handle_vec_value_getters;
use std::ffi::{c_char, CString}; use std::ffi::{c_char, CString};
/// Helper utility class to wrap a pointer for extern functions. /// Helper utility class to wrap a pointer for extern functions.
#[repr(C)] #[repr(C)]
pub(self) struct ExternPointer<T: ?Sized> { struct ExternPointer<T: ?Sized> {
/// The wrapped pointer. /// The wrapped pointer.
ptr: *mut T, ptr: *mut T,
} }

View File

@ -7,6 +7,7 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
#![allow(ambiguous_glob_reexports)] #![allow(ambiguous_glob_reexports)]
#![allow(hidden_glob_reexports)] #![allow(hidden_glob_reexports)]
#![allow(clippy::arc_with_non_send_sync)]
// Documentation linters // Documentation linters
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(clippy::missing_docs_in_private_items)] #![deny(clippy::missing_docs_in_private_items)]

View File

@ -24,10 +24,7 @@ impl<T: ?Sized> Copy for ExternRef<T> {}
impl<T: ?Sized> Clone for ExternRef<T> { impl<T: ?Sized> Clone for ExternRef<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { *self
index: self.index,
_phantom: Default::default(),
}
} }
} }
@ -148,11 +145,7 @@ pub(crate) struct VecExternRef<T> {
impl<T> Clone for VecExternRef<T> { impl<T> Clone for VecExternRef<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { *self
index: self.index,
size: self.size,
_phantom: Default::default(),
}
} }
} }

View File

@ -314,7 +314,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_move_type(env) { if let Some(func) = env.script_function_cache().change_move_type(env) {
let ptr = env.allocate_temp::<TypeIdentifier>(*move_type); let ptr = env.allocate_temp::<TypeIdentifier>(*move_type);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*move_type = *ptr.value(); *move_type = *ptr.value();
@ -335,7 +334,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_effectiveness(env) { if let Some(func) = env.script_function_cache().change_effectiveness(env) {
let ptr = env.allocate_temp(*effectiveness); let ptr = env.allocate_temp(*effectiveness);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*effectiveness = *ptr.value(); *effectiveness = *ptr.value();
@ -356,7 +354,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().block_critical(env) { if let Some(func) = env.script_function_cache().block_critical(env) {
let ptr = env.allocate_temp(*block_critical); let ptr = env.allocate_temp(*block_critical);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*block_critical = *ptr.value(); *block_critical = *ptr.value();
@ -377,7 +374,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().block_incoming_critical(env) { if let Some(func) = env.script_function_cache().block_incoming_critical(env) {
let ptr = env.allocate_temp(*block_critical); let ptr = env.allocate_temp(*block_critical);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*block_critical = *ptr.value(); *block_critical = *ptr.value();
@ -392,7 +388,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_accuracy(env) { if let Some(func) = env.script_function_cache().change_accuracy(env) {
let ptr = env.allocate_temp(*accuracy); let ptr = env.allocate_temp(*accuracy);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*accuracy = *ptr.value(); *accuracy = *ptr.value();
@ -407,7 +402,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_critical_stage(env) { if let Some(func) = env.script_function_cache().change_critical_stage(env) {
let ptr = env.allocate_temp(*stage); let ptr = env.allocate_temp(*stage);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*stage = *ptr.value(); *stage = *ptr.value();
@ -428,7 +422,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_critical_modifier(env) { if let Some(func) = env.script_function_cache().change_critical_modifier(env) {
let ptr = env.allocate_temp(*modifier); let ptr = env.allocate_temp(*modifier);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*modifier = *ptr.value(); *modifier = *ptr.value();
@ -449,7 +442,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_stab_modifier(env) { if let Some(func) = env.script_function_cache().change_stab_modifier(env) {
let ptr = env.allocate_temp(*modifier); let ptr = env.allocate_temp(*modifier);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*modifier = *ptr.value(); *modifier = *ptr.value();
@ -464,7 +456,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_base_power(env) { if let Some(func) = env.script_function_cache().change_base_power(env) {
let ptr = env.allocate_temp(*base_power); let ptr = env.allocate_temp(*base_power);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*base_power = *ptr.value(); *base_power = *ptr.value();
@ -485,7 +476,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().bypass_defensive_stat_boost(env) { if let Some(func) = env.script_function_cache().bypass_defensive_stat_boost(env) {
let ptr = env.allocate_temp(*bypass); let ptr = env.allocate_temp(*bypass);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*bypass = *ptr.value(); *bypass = *ptr.value();
@ -506,7 +496,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().bypass_offensive_stat_boost(env) { if let Some(func) = env.script_function_cache().bypass_offensive_stat_boost(env) {
let ptr = env.allocate_temp(*bypass); let ptr = env.allocate_temp(*bypass);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*bypass = *ptr.value(); *bypass = *ptr.value();
@ -527,7 +516,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_offensive_stat_value(env) { if let Some(func) = env.script_function_cache().change_offensive_stat_value(env) {
let ptr = env.allocate_temp(*amount); let ptr = env.allocate_temp(*amount);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*amount = *ptr.value(); *amount = *ptr.value();
@ -548,7 +536,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_defensive_stat_value(env) { if let Some(func) = env.script_function_cache().change_defensive_stat_value(env) {
let ptr = env.allocate_temp(*amount); let ptr = env.allocate_temp(*amount);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*amount = *ptr.value(); *amount = *ptr.value();
@ -569,7 +556,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_damage_stat_modifier(env) { if let Some(func) = env.script_function_cache().change_damage_stat_modifier(env) {
let ptr = env.allocate_temp(*modifier); let ptr = env.allocate_temp(*modifier);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*modifier = *ptr.value(); *modifier = *ptr.value();
@ -590,7 +576,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_damage_modifier(env) { if let Some(func) = env.script_function_cache().change_damage_modifier(env) {
let ptr = env.allocate_temp(*modifier); let ptr = env.allocate_temp(*modifier);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*modifier = *ptr.value(); *modifier = *ptr.value();
@ -605,7 +590,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_damage(env) { if let Some(func) = env.script_function_cache().change_damage(env) {
let ptr = env.allocate_temp(*damage); let ptr = env.allocate_temp(*damage);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*damage = *ptr.value(); *damage = *ptr.value();
@ -626,7 +610,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_incoming_damage(env) { if let Some(func) = env.script_function_cache().change_incoming_damage(env) {
let ptr = env.allocate_temp(*damage); let ptr = env.allocate_temp(*damage);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*damage = *ptr.value(); *damage = *ptr.value();
@ -640,7 +623,6 @@ impl Script for WebAssemblyScript {
} }
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().on_incoming_hit(env) { if let Some(func) = env.script_function_cache().on_incoming_hit(env) {
let target = target;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit);
} }
Ok(()) Ok(())
@ -652,7 +634,6 @@ impl Script for WebAssemblyScript {
} }
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().on_opponent_faints(env) { if let Some(func) = env.script_function_cache().on_opponent_faints(env) {
let target = target;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit);
} }
Ok(()) Ok(())
@ -701,7 +682,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().prevent_secondary_effect(env) { if let Some(func) = env.script_function_cache().prevent_secondary_effect(env) {
let ptr = env.allocate_temp(*prevent); let ptr = env.allocate_temp(*prevent);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*prevent = *ptr.value(); *prevent = *ptr.value();
@ -716,7 +696,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_effect_chance(env) { if let Some(func) = env.script_function_cache().change_effect_chance(env) {
let ptr = env.allocate_temp(*chance); let ptr = env.allocate_temp(*chance);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*chance = *ptr.value(); *chance = *ptr.value();
@ -737,7 +716,6 @@ impl Script for WebAssemblyScript {
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().change_incoming_effect_chance(env) { if let Some(func) = env.script_function_cache().change_incoming_effect_chance(env) {
let ptr = env.allocate_temp(*chance); let ptr = env.allocate_temp(*chance);
let target = target;
let w_ptr = ptr.wasm_ptr; let w_ptr = ptr.wasm_ptr;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit, w_ptr);
*chance = *ptr.value(); *chance = *ptr.value();
@ -751,7 +729,6 @@ impl Script for WebAssemblyScript {
} }
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().on_secondary_effect(env) { if let Some(func) = env.script_function_cache().on_secondary_effect(env) {
let target = target;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target), hit);
} }
Ok(()) Ok(())
@ -763,7 +740,6 @@ impl Script for WebAssemblyScript {
} }
let env = &self.environment; let env = &self.environment;
if let Some(func) = env.script_function_cache().on_after_hits(env) { if let Some(func) = env.script_function_cache().on_after_hits(env) {
let target = target;
call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target)); call_func!(func, env, self, ex_ref!(env, mv), ex_ref!(env, target));
} }
Ok(()) Ok(())

View File

@ -81,10 +81,7 @@ pub(super) struct WasmPtr<T> {
impl<T> Clone for WasmPtr<T> { impl<T> Clone for WasmPtr<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { *self
v: self.v,
_phantom: Default::default(),
}
} }
} }

View File

@ -1,6 +1,7 @@
#![feature(custom_test_frameworks)] #![feature(custom_test_frameworks)]
#![feature(lazy_cell)] #![feature(lazy_cell)]
#![allow(clippy::borrowed_box)] #![allow(clippy::borrowed_box)]
#![allow(clippy::arc_with_non_send_sync)]
use std::sync::{Arc, LazyLock}; use std::sync::{Arc, LazyLock};