diff --git a/embassy-hal-common/src/macros.rs b/embassy-hal-common/src/macros.rs index da791313..5e62e048 100644 --- a/embassy-hal-common/src/macros.rs +++ b/embassy-hal-common/src/macros.rs @@ -92,7 +92,7 @@ macro_rules! impl_peripheral { type P = $type; #[inline] - unsafe fn clone_unchecked(&mut self) -> Self::P { + unsafe fn clone_unchecked(&self) -> Self::P { $type { ..*self } } } diff --git a/embassy-hal-common/src/peripheral.rs b/embassy-hal-common/src/peripheral.rs index 4a6b6a60..c7133bac 100644 --- a/embassy-hal-common/src/peripheral.rs +++ b/embassy-hal-common/src/peripheral.rs @@ -39,7 +39,7 @@ impl<'a, T> PeripheralRef<'a, T> { /// You should strongly prefer using `reborrow()` instead. It returns a /// `PeripheralRef` that borrows `self`, which allows the borrow checker /// to enforce this at compile time. - pub unsafe fn clone_unchecked(&mut self) -> PeripheralRef<'a, T> + pub unsafe fn clone_unchecked(&self) -> PeripheralRef<'a, T> where T: Peripheral
,
{
@@ -146,14 +146,14 @@ pub trait Peripheral: Sized {
///
/// You should strongly prefer using `into_ref()` instead. It returns a
/// `PeripheralRef`, which allows the borrow checker to enforce this at compile time.
- unsafe fn clone_unchecked(&mut self) -> Self::P;
+ unsafe fn clone_unchecked(&self) -> Self::P;
/// Convert a value into a `PeripheralRef`.
///
/// When called on an owned `T`, yields a `PeripheralRef<'static, T>`.
/// When called on an `&'a mut T`, yields a `PeripheralRef<'a, T>`.
#[inline]
- fn into_ref<'a>(mut self) -> PeripheralRef<'a, Self::P>
+ fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P>
where
Self: 'a,
{
@@ -161,14 +161,14 @@ pub trait Peripheral: Sized {
}
}
-impl<'b, T: DerefMut> Peripheral for T
+impl<'b, T: Deref> Peripheral for T
where
T::Target: Peripheral,
{
type P = + 'd,
ppi_ch2: impl Peripheral + 'd,
) -> (UarteTx<'d, T>, UarteRxWithIdle<'d, T, U>) {
- let mut timer = Timer::new(timer);
+ let timer = Timer::new(timer);
into_ref!(ppi_ch1, ppi_ch2);
diff --git a/embassy-nrf/src/usb/mod.rs b/embassy-nrf/src/usb/mod.rs
index 56de511d..c1f3f48c 100644
--- a/embassy-nrf/src/usb/mod.rs
+++ b/embassy-nrf/src/usb/mod.rs
@@ -153,7 +153,7 @@ impl<'d, T: Instance, V: VbusDetect + 'd> driver::Driver<'d> for Driver<'d, T, V
}))
}
- fn start(mut self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) {
+ fn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) {
(
Bus {
_p: unsafe { self._p.clone_unchecked() },
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs
index b01e8ba4..73bd29fc 100644
--- a/embassy-stm32/build.rs
+++ b/embassy-stm32/build.rs
@@ -180,7 +180,7 @@ fn main() {
#[cfg(flash)]
impl<'d> FlashLayout<'d> {
- pub(crate) fn new(mut p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self {
+ pub(crate) fn new(p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self {
Self {
#(#inits),*
}
diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs
index 8235d6f0..1189e447 100644
--- a/embassy-stm32/src/flash/common.rs
+++ b/embassy-stm32/src/flash/common.rs
@@ -33,8 +33,7 @@ impl<'d> Flash<'d> {
}
pub(crate) fn release(self) -> PeripheralRef<'d, crate::peripherals::FLASH> {
- let mut flash = self;
- unsafe { flash.inner.clone_unchecked() }
+ unsafe { self.inner.clone_unchecked() }
}
}
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs
index 2ce9df69..60ac62c1 100644
--- a/embassy-stm32/src/flash/f4.rs
+++ b/embassy-stm32/src/flash/f4.rs
@@ -67,7 +67,7 @@ mod alt_regions {
// SAFETY: We never expose the cloned peripheral references, and their instance is not public.
// Also, all flash region operations are protected with a cs.
- let mut p = self.release();
+ let p = self.release();
AltFlashLayout {
bank1_region1: Bank1Region1(&BANK1_REGION1, unsafe { p.clone_unchecked() }),
bank1_region2: Bank1Region2(&BANK1_REGION2, unsafe { p.clone_unchecked() }),
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs
index 3024f1ff..4895684e 100644
--- a/embassy-stm32/src/gpio.rs
+++ b/embassy-stm32/src/gpio.rs
@@ -29,7 +29,7 @@ impl<'d, T: Pin> Flex<'d, T> {
}
#[inline]
- pub fn degrade(mut self) -> Flex<'d, AnyPin> {
+ pub fn degrade(self) -> Flex<'d, AnyPin> {
// Safety: We are about to drop the other copy of this pin, so
// this clone is safe.
let pin = unsafe { self.pin.clone_unchecked() };