Skip to content

Commit

Permalink
Silent a Rust compiler warning on invalid reference casting
Browse files Browse the repository at this point in the history
Using such a cast to set the `dr` register inside an `unsafe` block is
an acceptable way to access the data.
  • Loading branch information
samueltardieu committed Jan 30, 2024
1 parent 773836d commit 05d2dd9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ where
unsafe { ptr::read_volatile(&self.spi.dr as *const _ as *const FrameSize) }
}

#[allow(invalid_reference_casting)]
fn write_data_reg(&mut self, data: FrameSize) {
// NOTE(write_volatile) see note above
unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut FrameSize, data) }
Expand Down

0 comments on commit 05d2dd9

Please sign in to comment.