Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
dotcypress committed Apr 8, 2024
1 parent 0fea786 commit 7a348ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use crate::rcc::{Enable, Rcc, Reset};
use crate::stm32::CRC;
use core::hash::Hasher;
use core::{cell, ptr};

/// Extension trait to constrain the CRC peripheral.
pub trait CrcExt {
Expand Down Expand Up @@ -169,8 +170,9 @@ impl Crc {
pub fn feed(&mut self, data: &[u8]) {
let crc = unsafe { &(*CRC::ptr()) };
for byte in data {
let ptr = &crc.dr as *const _;
unsafe { core::ptr::write_volatile(ptr as *mut u8, *byte) };
unsafe {
ptr::write_volatile(cell::UnsafeCell::raw_get(&crc.dr as *const _ as _), byte)

Check failure on line 174 in src/crc.rs

View workflow job for this annotation

GitHub Actions / clippy

field `dr` of struct `stm32c0::stm32c031::crc::RegisterBlock` is private

error[E0616]: field `dr` of struct `stm32c0::stm32c031::crc::RegisterBlock` is private --> src/crc.rs:174:68 | 174 | ptr::write_volatile(cell::UnsafeCell::raw_get(&crc.dr as *const _ as _), byte) | ^^ private field | help: a method `dr` also exists, call it with parentheses | 174 | ptr::write_volatile(cell::UnsafeCell::raw_get(&crc.dr() as *const _ as _), byte) | ++
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ macro_rules! spi {
} else if sr.crcerr().bit_is_set() {
nb::Error::Other(Error::Crc)
} else if sr.txe().bit_is_set() {
let ptr = &self.spi.dr as *const _;
unsafe { core::ptr::write_volatile(ptr as *mut u8, byte) };
unsafe {
ptr::write_volatile(core::cell::UnsafeCell::raw_get(&self.spi.dr as *const _ as _), byte)

Check failure on line 266 in src/spi.rs

View workflow job for this annotation

GitHub Actions / clippy

field `dr` of struct `stm32c0::stm32c031::spi::RegisterBlock` is private

error[E0616]: field `dr` of struct `stm32c0::stm32c031::spi::RegisterBlock` is private --> src/spi.rs:266:87 | 266 | ptr::write_volatile(core::cell::UnsafeCell::raw_get(&self.spi.dr as *const _ as _), byte) | ^^ private field ... 281 | / spi!( 282 | | SPI, 283 | | spi1, 284 | | sck: [ ... | 302 | | ], 303 | | ); | |_- in this macro invocation | = note: this error originates in the macro `spi` (in Nightly builds, run with -Z macro-backtrace for more info) help: a method `dr` also exists, call it with parentheses | 266 | ptr::write_volatile(core::cell::UnsafeCell::raw_get(&self.spi.dr() as *const _ as _), byte) | ++
}
return Ok(());
} else {
nb::Error::WouldBlock
Expand Down

0 comments on commit 7a348ed

Please sign in to comment.