Merge pull request #322 from corwinkuiper/clippy-fixes

Clippy autofix
This commit is contained in:
Corwin 2022-10-08 12:20:02 +01:00 committed by GitHub
commit b9b08780ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 14 deletions

View file

@ -43,7 +43,7 @@ impl BumpAllocator {
let resulting_ptr = ptr + amount_to_add;
let new_current_ptr = resulting_ptr + layout.size();
if new_current_ptr as usize >= (self.start_end.borrow(cs).end)() {
if new_current_ptr >= (self.start_end.borrow(cs).end)() {
return None;
}

View file

@ -627,7 +627,7 @@ impl ObjectController {
unsafe {
(OBJECT_ATTRIBUTE_MEMORY as *mut u16)
.add((i as usize) * 4)
.add(i * 4)
.write_volatile(HIDDEN_VALUE);
}
@ -794,7 +794,7 @@ impl ObjectController {
});
let loan = Loan {
index: index as u8,
index,
phantom: PhantomData,
};
@ -916,8 +916,8 @@ impl<'a> Object<'a> {
/// [ObjectController::commit] is called.
pub fn set_x(&mut self, x: u16) -> &mut Self {
let object_inner = unsafe { self.object_inner() };
object_inner.attrs.a1a.set_x(x.rem_euclid(1 << 9) as u16);
object_inner.attrs.a1s.set_x(x.rem_euclid(1 << 9) as u16);
object_inner.attrs.a1a.set_x(x.rem_euclid(1 << 9));
object_inner.attrs.a1s.set_x(x.rem_euclid(1 << 9));
self
}

View file

@ -224,7 +224,7 @@ impl VRamManager {
slice::from_raw_parts_mut(
tiles
.as_mut_ptr()
.add((index * tile_format.tile_size()) as usize)
.add(index * tile_format.tile_size())
.cast(),
tile_format.tile_size() / core::mem::size_of::<u32>(),
)

View file

@ -51,7 +51,7 @@ fn set_bank(bank: u8) -> Result<(), Error> {
Err(Error::OutOfBounds)
} else if bank != CURRENT_BANK.read() {
issue_flash_command(CMD_SET_BANK);
FLASH_PORT_BANK.set(bank as u8);
FLASH_PORT_BANK.set(bank);
CURRENT_BANK.write(bank);
Ok(())
} else {

View file

@ -207,7 +207,7 @@ impl RolledDice {
let heal = *face_counts.entry(Face::Heal).or_default();
if heal != 0 {
actions.push(Action::PlayerHeal {
amount: ((heal * (heal + 1)) / 2) as u32,
amount: (heal * (heal + 1)) / 2,
});
}

View file

@ -129,7 +129,7 @@ impl<'a> Level<'a> {
let factor: Number = Number::new(1) / Number::new(8);
let (x, y) = (v * factor).floor().get();
if (x < 0 || x > tilemap::WIDTH as i32) || (y < 0 || y > tilemap::HEIGHT as i32) {
if !(0..=tilemap::WIDTH).contains(&x) || !(0..=tilemap::HEIGHT).contains(&y) {
return Some(Rect::new((x * 8, y * 8).into(), (8, 8).into()));
}
let position = tilemap::WIDTH as usize * y as usize + x as usize;
@ -1878,7 +1878,7 @@ enum MoveState {
impl<'a> Game<'a> {
fn has_just_reached_end(&self) -> bool {
match self.boss {
BossState::NotSpawned => self.offset.x.floor() + 248 >= tilemap::WIDTH as i32 * 8,
BossState::NotSpawned => self.offset.x.floor() + 248 >= tilemap::WIDTH * 8,
_ => false,
}
}
@ -1901,13 +1901,13 @@ impl<'a> Game<'a> {
if self.has_just_reached_end() {
sfx.boss();
self.offset.x = (tilemap::WIDTH as i32 * 8 - 248).into();
self.offset.x = (tilemap::WIDTH * 8 - 248).into();
self.move_state = MoveState::PinnedAtEnd;
self.boss = BossState::Active(Boss::new(object_controller, self.offset))
}
}
MoveState::PinnedAtEnd => {
self.offset.x = (tilemap::WIDTH as i32 * 8 - 248).into();
self.offset.x = (tilemap::WIDTH * 8 - 248).into();
}
MoveState::FollowingPlayer => {
Game::update_sunrise(vram, self.sunrise_timer);
@ -1917,8 +1917,8 @@ impl<'a> Game<'a> {
let difference = self.player.entity.position.x - (self.offset.x + WIDTH / 2);
self.offset.x += difference / 8;
if self.offset.x > (tilemap::WIDTH as i32 * 8 - 248).into() {
self.offset.x = (tilemap::WIDTH as i32 * 8 - 248).into();
if self.offset.x > (tilemap::WIDTH * 8 - 248).into() {
self.offset.x = (tilemap::WIDTH * 8 - 248).into();
} else if self.offset.x < 8.into() {
self.offset.x = 8.into();
self.move_state = MoveState::Ending;