Fix clippy and use nightly for CI builds (#540)

This commit is contained in:
Corwin 2024-01-13 10:46:06 +00:00 committed by GitHub
commit 156fe0fe7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 69 additions and 57 deletions

View file

@ -10,7 +10,8 @@ on:
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: ${{ !github.event.schedule && 'nightly-2023-12-01' || 'nightly' }} # RUSTUP_TOOLCHAIN: ${{ !github.event.schedule && 'nightly-2023-12-01' || 'nightly' }}
RUSTUP_TOOLCHAIN: "nightly"
jobs: jobs:
build: build:

View file

@ -44,6 +44,12 @@
}, },
{ {
"path": "../agb-hashmap" "path": "../agb-hashmap"
},
{
"path": "../examples/amplitude"
},
{
"path": "../examples/the-dungeon-puzzlers-lament"
} }
] ]
} }

View file

@ -387,6 +387,8 @@ pub(crate) fn program_counter_before_interrupt() -> u32 {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use core::ptr::addr_of_mut;
use super::Gba; use super::Gba;
#[test_case] #[test_case]
@ -415,11 +417,11 @@ mod test {
} }
#[link_section = ".ewram"] #[link_section = ".ewram"]
static mut EWRAM_TEST: u32 = 5; static mut EWART_TEST: u32 = 5;
#[test_case] #[test_case]
fn ewram_static_test(_gba: &mut Gba) { fn ewram_static_test(_gba: &mut Gba) {
unsafe { unsafe {
let ewram_ptr = &mut EWRAM_TEST as *mut u32; let ewram_ptr = addr_of_mut!(EWART_TEST);
let content = ewram_ptr.read_volatile(); let content = ewram_ptr.read_volatile();
assert_eq!(content, 5, "expected data in ewram to be 5"); assert_eq!(content, 5, "expected data in ewram to be 5");
ewram_ptr.write_volatile(content + 1); ewram_ptr.write_volatile(content + 1);
@ -438,7 +440,7 @@ mod test {
#[test_case] #[test_case]
fn iwram_explicit_test(_gba: &mut Gba) { fn iwram_explicit_test(_gba: &mut Gba) {
unsafe { unsafe {
let iwram_ptr = &mut IWRAM_EXPLICIT as *mut u32; let iwram_ptr = addr_of_mut!(IWRAM_EXPLICIT);
let address = iwram_ptr as usize; let address = iwram_ptr as usize;
assert!( assert!(
(0x0300_0000..0x0300_8000).contains(&address), (0x0300_0000..0x0300_8000).contains(&address),
@ -456,7 +458,7 @@ mod test {
#[test_case] #[test_case]
fn implicit_data_test(_gba: &mut Gba) { fn implicit_data_test(_gba: &mut Gba) {
unsafe { unsafe {
let iwram_ptr = &mut IMPLICIT_STORAGE as *mut u32; let iwram_ptr = addr_of_mut!(IMPLICIT_STORAGE);
let address = iwram_ptr as usize; let address = iwram_ptr as usize;
assert!( assert!(
(0x0200_0000..0x0204_0000).contains(&address), (0x0200_0000..0x0204_0000).contains(&address),

View file

@ -243,7 +243,7 @@ static CHIP_INFO: InitOnce<&'static ChipInfo> = InitOnce::new();
fn cached_chip_info() -> Result<&'static ChipInfo, Error> { fn cached_chip_info() -> Result<&'static ChipInfo, Error> {
CHIP_INFO CHIP_INFO
.try_get(|| -> Result<_, Error> { Ok(FlashChipType::detect()?.chip_info()) }) .try_get(|| -> Result<_, Error> { Ok(FlashChipType::detect()?.chip_info()) })
.map(Clone::clone) .cloned()
} }
/// Actual implementation of the ChipInfo functions. /// Actual implementation of the ChipInfo functions.

View file

@ -186,7 +186,7 @@ struct Game {
enum GameState { enum GameState {
Continue, Continue,
Loss(u32), Loss,
} }
impl Game { impl Game {
@ -314,7 +314,7 @@ impl Game {
|| (self.head_position.y + 1).floor() > display::HEIGHT + 4; || (self.head_position.y + 1).floor() > display::HEIGHT + 4;
if saw_has_hit_head || out_of_bounds_death { if saw_has_hit_head || out_of_bounds_death {
GameState::Loss(self.alive_frames) GameState::Loss
} else { } else {
GameState::Continue GameState::Continue
} }
@ -443,7 +443,7 @@ pub fn main(mut gba: agb::Gba) -> ! {
game.render(oam_frame, &sprite_cache); game.render(oam_frame, &sprite_cache);
if let GameState::Loss(_) = state { if matches!(state, GameState::Loss) {
for _ in 0..30 { for _ in 0..30 {
vblank.wait_for_vblank(); vblank.wait_for_vblank();
} }

View file

@ -1074,6 +1074,9 @@ mod tests {
} }
#[derive(Debug)] #[derive(Debug)]
// allow dead code because field is unused apart from in a debug string,
// which is what we want to use it for.
#[allow(dead_code)]
enum CompleteSimulationResult { enum CompleteSimulationResult {
Success, Success,
ExplicitLoss, ExplicitLoss,