diff --git a/core/src/cpu.rs b/core/src/cpu.rs index e7ce43c..1aff255 100644 --- a/core/src/cpu.rs +++ b/core/src/cpu.rs @@ -1,7 +1,7 @@ pub mod bus; pub mod psr; pub mod schedule; -pub(crate) use schedule::{Schedule, ScheduleConst}; +pub(crate) use schedule::Schedule; mod irqs; pub(crate) use irqs::Irqs; #[cfg(any(feature = "debugger-hooks", doc))] diff --git a/core/src/cpu/arm7/schedule.rs b/core/src/cpu/arm7/schedule.rs index 82d7cf9..2cd38f4 100644 --- a/core/src/cpu/arm7/schedule.rs +++ b/core/src/cpu/arm7/schedule.rs @@ -115,18 +115,11 @@ impl Schedule { } } -impl const cpu::ScheduleConst for Schedule { +impl cpu::Schedule for Schedule { type Timestamp = Timestamp; type Event = Event; type EventSlotIndex = EventSlotIndex; - #[inline] - fn timer_event_slot(i: timers::Index) -> EventSlotIndex { - EventSlotIndex::new(event_slots::TIMERS_START.get() + i.get()) - } -} - -impl cpu::Schedule for Schedule { #[inline] fn cur_time(&self) -> Timestamp { self.cur_time @@ -152,12 +145,15 @@ impl cpu::Schedule for Schedule { self.schedule.set_event(slot_index, event); } + #[inline] + fn timer_event_slot(i: timers::Index) -> EventSlotIndex { + EventSlotIndex::new(event_slots::TIMERS_START.get() + i.get()) + } + #[inline] fn set_timer_event(&mut self, i: timers::Index) { - self.schedule.set_event( - ::timer_event_slot(i), - Event::Timer(i), - ); + self.schedule + .set_event(Self::timer_event_slot(i), Event::Timer(i)); } #[inline] diff --git a/core/src/cpu/arm9/bus/ptrs.rs b/core/src/cpu/arm9/bus/ptrs.rs index 70ae362..954c558 100644 --- a/core/src/cpu/arm9/bus/ptrs.rs +++ b/core/src/cpu/arm9/bus/ptrs.rs @@ -54,6 +54,7 @@ cfg_if::cfg_if! { } } +#[allow(clippy::struct_field_names)] #[repr(C)] pub struct Ptrs { ptrs: [*mut u8; Self::ENTRIES], diff --git a/core/src/cpu/arm9/cp15/ptrs.rs b/core/src/cpu/arm9/cp15/ptrs.rs index b51dd90..54898c4 100644 --- a/core/src/cpu/arm9/cp15/ptrs.rs +++ b/core/src/cpu/arm9/cp15/ptrs.rs @@ -80,6 +80,7 @@ mod mask { pub const ALL: Mask = R_ALL | W_ALL; } +#[allow(clippy::struct_field_names)] #[repr(C)] pub struct Ptrs { r_code_ptrs: [*const u8; Self::ENTRIES], diff --git a/core/src/cpu/arm9/schedule.rs b/core/src/cpu/arm9/schedule.rs index eb2a086..4611cb4 100644 --- a/core/src/cpu/arm9/schedule.rs +++ b/core/src/cpu/arm9/schedule.rs @@ -90,18 +90,11 @@ impl Schedule { } } -impl const cpu::ScheduleConst for Schedule { +impl cpu::Schedule for Schedule { type Timestamp = Timestamp; type Event = Event; type EventSlotIndex = EventSlotIndex; - #[inline] - fn timer_event_slot(i: timers::Index) -> EventSlotIndex { - EventSlotIndex::new(event_slots::TIMERS_START.get() + i.get()) - } -} - -impl cpu::Schedule for Schedule { #[inline] fn cur_time(&self) -> Timestamp { self.cur_time @@ -127,12 +120,15 @@ impl cpu::Schedule for Schedule { self.schedule.set_event(slot_index, event); } + #[inline] + fn timer_event_slot(i: timers::Index) -> EventSlotIndex { + EventSlotIndex::new(event_slots::TIMERS_START.get() + i.get()) + } + #[inline] fn set_timer_event(&mut self, i: timers::Index) { - self.schedule.set_event( - ::timer_event_slot(i), - Event::Timer(i), - ); + self.schedule + .set_event(Self::timer_event_slot(i), Event::Timer(i)); } #[inline] diff --git a/core/src/cpu/debug.rs b/core/src/cpu/debug.rs index 34578c5..ef80915 100644 --- a/core/src/cpu/debug.rs +++ b/core/src/cpu/debug.rs @@ -77,9 +77,13 @@ impl MemWatchpointRootTable { pub(super) fn remove(&mut self, addr: u32, size: u8, rw: MemWatchpointRwMask) { let root_i = (addr >> 21) as usize; - let Some(sub_table) = &mut self.0[root_i] else { return }; + let Some(sub_table) = &mut self.0[root_i] else { + return; + }; let sub_i = (addr >> 10 & 0x7FF) as usize; - let Some(leaf_table) = &mut sub_table.0[sub_i] else { return }; + let Some(leaf_table) = &mut sub_table.0[sub_i] else { + return; + }; let mut mask = rw.bits() as usize; for i in 0..size.trailing_zeros() { mask |= mask << (2 << i); diff --git a/core/src/cpu/schedule.rs b/core/src/cpu/schedule.rs index e5ffe33..d0ed5e2 100644 --- a/core/src/cpu/schedule.rs +++ b/core/src/cpu/schedule.rs @@ -4,8 +4,7 @@ use crate::{ utils::{Loadable, LoadableInPlace, Storable}, }; -#[const_trait] -pub trait ScheduleConst { +pub trait Schedule { type Timestamp: Copy + From + Into @@ -21,10 +20,6 @@ pub trait ScheduleConst { type Event: Copy + Loadable + LoadableInPlace + Storable; type EventSlotIndex: Copy + Loadable + LoadableInPlace + Storable; - fn timer_event_slot(i: timers::Index) -> Self::EventSlotIndex; -} - -pub trait Schedule: ~const ScheduleConst { fn cur_time(&self) -> Self::Timestamp; fn set_cur_time(&mut self, value: Self::Timestamp); #[inline] @@ -40,6 +35,8 @@ pub trait Schedule: ~const ScheduleConst { } fn set_event(&mut self, slot_index: Self::EventSlotIndex, event: Self::Event); + + fn timer_event_slot(i: timers::Index) -> Self::EventSlotIndex; fn set_timer_event(&mut self, i: timers::Index); fn schedule_event(&mut self, slot_index: Self::EventSlotIndex, time: Self::Timestamp); diff --git a/core/src/emu.rs b/core/src/emu.rs index 4213a94..e506614 100644 --- a/core/src/emu.rs +++ b/core/src/emu.rs @@ -283,7 +283,7 @@ impl Builder { ds_rom .setup(self.direct_boot) - .map_err(|_| BuildError::RomNeedsDecryptionButNoBiosProvided)?; + .map_err(|()| BuildError::RomNeedsDecryptionButNoBiosProvided)?; let (global_engine_data, arm7_engine_data, arm9_engine_data) = engine.into_data(); let mut arm7 = Arm7::new( diff --git a/core/src/gpu/engine_3d.rs b/core/src/gpu/engine_3d.rs index ff0a1ba..b6700dc 100644 --- a/core/src/gpu/engine_3d.rs +++ b/core/src/gpu/engine_3d.rs @@ -17,7 +17,12 @@ use crate::{ }; use core::{ mem::{replace, transmute, MaybeUninit}, - simd::{i32x4, u32x2, u64x2, SimdInt, SimdOrd, SimdUint}, + simd::{ + cmp::SimdOrd, + i32x4, + num::{SimdInt, SimdUint}, + u32x2, u64x2, + }, }; use matrix::{Matrix, MatrixBuffer}; use vertex::Vertex; diff --git a/core/src/gpu/engine_3d/matrix.rs b/core/src/gpu/engine_3d/matrix.rs index a29b4a6..3c6368e 100644 --- a/core/src/gpu/engine_3d/matrix.rs +++ b/core/src/gpu/engine_3d/matrix.rs @@ -1,6 +1,6 @@ use crate::utils::Savestate; use core::ops::Mul; -use core::simd::{i32x4, i64x4, Simd, SimdCast, SimdElement, SimdInt}; +use core::simd::{i32x4, i64x4, num::SimdInt, Simd, SimdCast, SimdElement}; #[derive(Clone, Copy, Debug)] #[repr(align(16))] diff --git a/core/src/gpu/engine_3d/vertex.rs b/core/src/gpu/engine_3d/vertex.rs index 3fdffdd..3be1bab 100644 --- a/core/src/gpu/engine_3d/vertex.rs +++ b/core/src/gpu/engine_3d/vertex.rs @@ -1,7 +1,9 @@ use crate::utils::Savestate; use core::simd::{ - i16x2, i32x4, i64x2, i64x4, mask64x4, simd_swizzle, u16x2, u16x4, u8x4, SimdInt, SimdPartialEq, - SimdUint, + cmp::SimdPartialEq, + i16x2, i32x4, i64x2, i64x4, mask64x4, + num::{SimdInt, SimdUint}, + simd_swizzle, u16x2, u16x4, u8x4, }; pub type TexCoords = i16x2; diff --git a/core/src/lib.rs b/core/src/lib.rs index b069fa1..16e60c3 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -9,7 +9,6 @@ maybe_uninit_slice, portable_simd, const_mut_refs, - const_trait_impl, const_for, new_uninit )] diff --git a/frontend/desktop/src/audio/input/cpal.rs b/frontend/desktop/src/audio/input/cpal.rs index 92e5ddf..480593b 100644 --- a/frontend/desktop/src/audio/input/cpal.rs +++ b/frontend/desktop/src/audio/input/cpal.rs @@ -90,7 +90,10 @@ struct InputData { } impl InputData { - fn fill(&mut self, data: &[T]) where f64: cpal::FromSample { + fn fill(&mut self, data: &[T]) + where + f64: cpal::FromSample, + { if let Some(interp) = self.interp_rx.try_iter().last() { self.interp = interp; } diff --git a/frontend/desktop/src/input.rs b/frontend/desktop/src/input.rs index 7a26016..fb9f66c 100644 --- a/frontend/desktop/src/input.rs +++ b/frontend/desktop/src/input.rs @@ -2,8 +2,8 @@ mod map; pub use map::Map; mod state; pub use state::{Changes, State}; -pub mod trigger; pub mod key_codes; +pub mod trigger; pub use key_codes::{KeyCode, ScanCode}; use winit::keyboard::PhysicalKey; diff --git a/frontend/desktop/src/input/trigger.rs b/frontend/desktop/src/input/trigger.rs index 901c74a..0e126da 100644 --- a/frontend/desktop/src/input/trigger.rs +++ b/frontend/desktop/src/input/trigger.rs @@ -62,11 +62,7 @@ impl Trigger { impl ToString for Trigger { fn to_string(&self) -> String { - fn write_trigger( - result: &mut String, - trigger: &Trigger, - needs_parens_if_multiple: bool, - ) { + fn write_trigger(result: &mut String, trigger: &Trigger, needs_parens_if_multiple: bool) { match trigger { &Trigger::KeyCode(key_code) => { write!(result, "v{}", <&str>::from(key_code)).unwrap(); @@ -273,7 +269,7 @@ impl<'a> TriggerParser<'a> { kind: ParseErrorKind::ExpectedValue, }); } - + if let Some(op) = op { return Ok(Trigger::Chain(op, values)); } else { diff --git a/frontend/desktop/src/ui/savestate_editor.rs b/frontend/desktop/src/ui/savestate_editor.rs index 2c30fe3..9f7b4cd 100644 --- a/frontend/desktop/src/ui/savestate_editor.rs +++ b/frontend/desktop/src/ui/savestate_editor.rs @@ -314,7 +314,7 @@ impl Editor { for [a, b] in chunks { text_heights.push(text_height(a).max(text_height(b))); } - if let Some(last) = last.get(0) { + if let Some(last) = last.first() { text_heights.push(text_height(last)); } } diff --git a/frontend/desktop/src/ui/window.rs b/frontend/desktop/src/ui/window.rs index 2ba6cc7..423ae96 100644 --- a/frontend/desktop/src/ui/window.rs +++ b/frontend/desktop/src/ui/window.rs @@ -46,7 +46,8 @@ impl GfxState { backends: wgpu::Backends::all(), ..Default::default() }); - let surface = unsafe { instance.create_surface_from_raw(window) }.expect("Couldn't create surface"); + let surface = + unsafe { instance.create_surface_from_raw(window) }.expect("Couldn't create surface"); let adapter = match adapter { AdapterSelection::Auto(power_preference) => { @@ -85,7 +86,7 @@ impl GfxState { format: { let formats = surface.get_capabilities(&adapter).formats; let preferred = formats - .get(0) + .first() .expect("Couldn't get surface preferred format"); #[cfg(target_os = "macos")] { @@ -155,7 +156,7 @@ impl GfxState { .surface .get_capabilities(&self.adapter) .formats - .get(0) + .first() .expect("Couldn't get surface preferred format"); if new_format != self.surface_config.format { self.surface_config.format = new_format; diff --git a/render/soft-3d/src/lib.rs b/render/soft-3d/src/lib.rs index fae972c..2d34164 100644 --- a/render/soft-3d/src/lib.rs +++ b/render/soft-3d/src/lib.rs @@ -5,7 +5,7 @@ mod data; pub use data::RenderingData; mod utils; -use core::simd::{SimdOrd, SimdUint}; +use core::simd::{cmp::SimdOrd, num::SimdUint}; use dust_core::gpu::{ engine_3d::{ Color, InterpColor, PolyAddr, PolyVertIndex, PolygonAttrs, TexCoords, TextureParams, diff --git a/render/soft-3d/src/utils.rs b/render/soft-3d/src/utils.rs index 7e20d46..9e5b029 100644 --- a/render/soft-3d/src/utils.rs +++ b/render/soft-3d/src/utils.rs @@ -1,4 +1,9 @@ -use core::simd::{i32x2, i64x2, u32x4, u64x4, SimdInt, SimdPartialEq, SimdPartialOrd, SimdUint}; +use core::simd::{ + cmp::{SimdPartialEq, SimdPartialOrd}, + i32x2, i64x2, + num::{SimdInt, SimdUint}, + u32x4, u64x4, +}; use dust_core::gpu::engine_3d::{ InterpColor, PolyVertIndex, PolyVertsLen, Polygon, ScreenVertex, TexCoords, VertexAddr, }; diff --git a/render/wgpu-3d/src/lib.rs b/render/wgpu-3d/src/lib.rs index 7c2a0b8..6c1f13a 100644 --- a/render/wgpu-3d/src/lib.rs +++ b/render/wgpu-3d/src/lib.rs @@ -19,7 +19,7 @@ mod utils; use ahash::AHashMap as HashMap; use core::{ mem::{self, MaybeUninit}, - simd::SimdUint, + simd::num::SimdUint, // simd::u16x2, slice, }; diff --git a/render/wgpu-3d/src/utils.rs b/render/wgpu-3d/src/utils.rs index c8bf0c6..9089607 100644 --- a/render/wgpu-3d/src/utils.rs +++ b/render/wgpu-3d/src/utils.rs @@ -1,4 +1,4 @@ -use core::simd::{f64x4, SimdUint}; +use core::simd::{f64x4, num::SimdUint}; use dust_core::gpu::engine_3d::Color; #[inline]