diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-10-18 00:55:43 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-10-18 01:05:29 +0200 |
| commit | a2e7c24e0055d13a61345dfce9fbe7fcf4e0d306 (patch) | |
| tree | 2f08fb1e2ed983259ae9eec59f21dbd1e41c5091 | |
| parent | d81a203ee264c8bb77eaae18944d4cace7b1683c (diff) | |
Clippy fixes
| -rw-r--r-- | .vscode/settings.json | 1 | ||||
| -rw-r--r-- | embassy-hal-common/src/lib.rs | 1 | ||||
| -rw-r--r-- | embassy-macros/src/lib.rs | 1 | ||||
| -rw-r--r-- | embassy-net/src/lib.rs | 1 | ||||
| -rw-r--r-- | embassy-net/src/stack.rs | 12 | ||||
| -rw-r--r-- | embassy-net/src/tcp_socket.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/gpio.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 1 | ||||
| -rw-r--r-- | embassy-traits/src/delay.rs | 4 | ||||
| -rw-r--r-- | embassy-traits/src/flash.rs | 2 | ||||
| -rw-r--r-- | embassy-traits/src/gpio.rs | 10 | ||||
| -rw-r--r-- | embassy-traits/src/rng.rs | 6 | ||||
| -rw-r--r-- | embassy/src/channel/mpsc.rs | 6 | ||||
| -rw-r--r-- | embassy/src/executor/raw/util.rs | 1 | ||||
| -rw-r--r-- | embassy/src/executor/spawner.rs | 2 | ||||
| -rw-r--r-- | embassy/src/io/util/read_exact.rs | 2 | ||||
| -rw-r--r-- | embassy/src/io/util/write_all.rs | 2 | ||||
| -rw-r--r-- | embassy/src/lib.rs | 1 | ||||
| -rw-r--r-- | embassy/src/time/delay.rs | 4 | ||||
| -rw-r--r-- | embassy/src/util/forever.rs | 3 |
20 files changed, 35 insertions, 29 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index a5a656637..2be7ffbe0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | "rust-analyzer.assist.importGranularity": "module", | 4 | "rust-analyzer.assist.importGranularity": "module", |
| 5 | "rust-analyzer.checkOnSave.allFeatures": false, | 5 | "rust-analyzer.checkOnSave.allFeatures": false, |
| 6 | "rust-analyzer.checkOnSave.allTargets": false, | 6 | "rust-analyzer.checkOnSave.allTargets": false, |
| 7 | "rust-analyzer.checkOnSave.command": "clippy", | ||
| 7 | "rust-analyzer.cargo.noDefaultFeatures": true, | 8 | "rust-analyzer.cargo.noDefaultFeatures": true, |
| 8 | "rust-analyzer.checkOnSave.noDefaultFeatures": true, | 9 | "rust-analyzer.checkOnSave.noDefaultFeatures": true, |
| 9 | "rust-analyzer.cargo.target": "thumbv7em-none-eabi", | 10 | "rust-analyzer.cargo.target": "thumbv7em-none-eabi", |
diff --git a/embassy-hal-common/src/lib.rs b/embassy-hal-common/src/lib.rs index 01e2d3aee..1af30c6b4 100644 --- a/embassy-hal-common/src/lib.rs +++ b/embassy-hal-common/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(clippy::new_without_default)] | ||
| 2 | 3 | ||
| 3 | // This mod MUST go first, so that the others see its macros. | 4 | // This mod MUST go first, so that the others see its macros. |
| 4 | pub(crate) mod fmt; | 5 | pub(crate) mod fmt; |
diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs index 708eed4cd..da08a59c3 100644 --- a/embassy-macros/src/lib.rs +++ b/embassy-macros/src/lib.rs | |||
| @@ -118,6 +118,7 @@ pub fn task(args: TokenStream, item: TokenStream) -> TokenStream { | |||
| 118 | use #embassy_path::executor::raw::TaskStorage; | 118 | use #embassy_path::executor::raw::TaskStorage; |
| 119 | #task_fn | 119 | #task_fn |
| 120 | type F = #impl_ty; | 120 | type F = #impl_ty; |
| 121 | #[allow(clippy::declare_interior_mutable_const)] | ||
| 121 | const NEW_TASK: TaskStorage<F> = TaskStorage::new(); | 122 | const NEW_TASK: TaskStorage<F> = TaskStorage::new(); |
| 122 | static POOL: [TaskStorage<F>; #pool_size] = [NEW_TASK; #pool_size]; | 123 | static POOL: [TaskStorage<F>; #pool_size] = [NEW_TASK; #pool_size]; |
| 123 | unsafe { TaskStorage::spawn_pool(&POOL, move || task(#arg_names)) } | 124 | unsafe { TaskStorage::spawn_pool(&POOL, move || task(#arg_names)) } |
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index 47a3650b0..db2a7ebd4 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![cfg_attr(not(feature = "std"), no_std)] | 1 | #![cfg_attr(not(feature = "std"), no_std)] |
| 2 | #![allow(clippy::new_without_default)] | ||
| 2 | 3 | ||
| 3 | // This mod MUST go first, so that the others see its macros. | 4 | // This mod MUST go first, so that the others see its macros. |
| 4 | pub(crate) mod fmt; | 5 | pub(crate) mod fmt; |
diff --git a/embassy-net/src/stack.rs b/embassy-net/src/stack.rs index f26808cd0..42defdcaf 100644 --- a/embassy-net/src/stack.rs +++ b/embassy-net/src/stack.rs | |||
| @@ -140,7 +140,7 @@ impl Stack { | |||
| 140 | self.waker.register(cx.waker()); | 140 | self.waker.register(cx.waker()); |
| 141 | 141 | ||
| 142 | let timestamp = instant_to_smoltcp(Instant::now()); | 142 | let timestamp = instant_to_smoltcp(Instant::now()); |
| 143 | if let Err(_) = self.iface.poll(&mut self.sockets, timestamp) { | 143 | if self.iface.poll(&mut self.sockets, timestamp).is_err() { |
| 144 | // If poll() returns error, it may not be done yet, so poll again later. | 144 | // If poll() returns error, it may not be done yet, so poll again later. |
| 145 | cx.waker().wake_by_ref(); | 145 | cx.waker().wake_by_ref(); |
| 146 | return; | 146 | return; |
| @@ -152,18 +152,14 @@ impl Stack { | |||
| 152 | 152 | ||
| 153 | // Print when changed | 153 | // Print when changed |
| 154 | if old_link_up != self.link_up { | 154 | if old_link_up != self.link_up { |
| 155 | if self.link_up { | 155 | info!("link_up = {:?}", self.link_up); |
| 156 | info!("Link up!"); | ||
| 157 | } else { | ||
| 158 | info!("Link down!"); | ||
| 159 | } | ||
| 160 | } | 156 | } |
| 161 | 157 | ||
| 162 | if old_link_up || self.link_up { | 158 | if old_link_up || self.link_up { |
| 163 | self.poll_configurator(timestamp) | 159 | self.poll_configurator(timestamp) |
| 164 | } | 160 | } |
| 165 | 161 | ||
| 166 | if let Some(poll_at) = self.iface.poll_at(&mut self.sockets, timestamp) { | 162 | if let Some(poll_at) = self.iface.poll_at(&self.sockets, timestamp) { |
| 167 | let t = Timer::at(instant_from_smoltcp(poll_at)); | 163 | let t = Timer::at(instant_from_smoltcp(poll_at)); |
| 168 | pin_mut!(t); | 164 | pin_mut!(t); |
| 169 | if t.poll(cx).is_ready() { | 165 | if t.poll(cx).is_ready() { |
| @@ -215,7 +211,7 @@ pub fn init<const ADDR: usize, const SOCK: usize, const NEIGH: usize>( | |||
| 215 | let mut res = [0u8; 2]; | 211 | let mut res = [0u8; 2]; |
| 216 | rand(&mut res); | 212 | rand(&mut res); |
| 217 | let port = u16::from_le_bytes(res); | 213 | let port = u16::from_le_bytes(res); |
| 218 | if port >= LOCAL_PORT_MIN && port <= LOCAL_PORT_MAX { | 214 | if (LOCAL_PORT_MIN..=LOCAL_PORT_MAX).contains(&port) { |
| 219 | break port; | 215 | break port; |
| 220 | } | 216 | } |
| 221 | }; | 217 | }; |
diff --git a/embassy-net/src/tcp_socket.rs b/embassy-net/src/tcp_socket.rs index 25c8af459..2433771c8 100644 --- a/embassy-net/src/tcp_socket.rs +++ b/embassy-net/src/tcp_socket.rs | |||
| @@ -130,7 +130,7 @@ impl<'a> AsyncBufRead for TcpSocket<'a> { | |||
| 130 | ) -> Poll<io::Result<&'z [u8]>> { | 130 | ) -> Poll<io::Result<&'z [u8]>> { |
| 131 | self.with(|socket| match socket.peek(1 << 30) { | 131 | self.with(|socket| match socket.peek(1 << 30) { |
| 132 | // No data ready | 132 | // No data ready |
| 133 | Ok(buf) if buf.len() == 0 => { | 133 | Ok(buf) if buf.is_empty() => { |
| 134 | socket.register_recv_waker(cx.waker()); | 134 | socket.register_recv_waker(cx.waker()); |
| 135 | Poll::Pending | 135 | Poll::Pending |
| 136 | } | 136 | } |
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index be0fac2b0..7896945fb 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs | |||
| @@ -443,7 +443,7 @@ pub trait OptionalPin: Unborrow<Target = Self> + sealed::OptionalPin + Sized { | |||
| 443 | 443 | ||
| 444 | #[inline] | 444 | #[inline] |
| 445 | fn psel_bits(&self) -> u32 { | 445 | fn psel_bits(&self) -> u32 { |
| 446 | self.pin().map_or(1u32 << 31, |pin| Pin::psel_bits(pin)) | 446 | self.pin().map_or(1u32 << 31, Pin::psel_bits) |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | /// Convert from concrete pin type PX_XX to type erased `Option<AnyPin>`. | 449 | /// Convert from concrete pin type PX_XX to type erased `Option<AnyPin>`. |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index bab49cebb..7ec072ac8 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -22,6 +22,7 @@ pub const PIN_COUNT: usize = 48; | |||
| 22 | #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] | 22 | #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] |
| 23 | pub const PIN_COUNT: usize = 32; | 23 | pub const PIN_COUNT: usize = 32; |
| 24 | 24 | ||
| 25 | #[allow(clippy::declare_interior_mutable_const)] | ||
| 25 | const NEW_AW: AtomicWaker = AtomicWaker::new(); | 26 | const NEW_AW: AtomicWaker = AtomicWaker::new(); |
| 26 | static CHANNEL_WAKERS: [AtomicWaker; CHANNEL_COUNT] = [NEW_AW; CHANNEL_COUNT]; | 27 | static CHANNEL_WAKERS: [AtomicWaker; CHANNEL_COUNT] = [NEW_AW; CHANNEL_COUNT]; |
| 27 | static PORT_WAKERS: [AtomicWaker; PIN_COUNT] = [NEW_AW; PIN_COUNT]; | 28 | static PORT_WAKERS: [AtomicWaker; PIN_COUNT] = [NEW_AW; PIN_COUNT]; |
diff --git a/embassy-traits/src/delay.rs b/embassy-traits/src/delay.rs index 31239d319..caa0b100a 100644 --- a/embassy-traits/src/delay.rs +++ b/embassy-traits/src/delay.rs | |||
| @@ -4,8 +4,8 @@ pub trait Delay { | |||
| 4 | type DelayFuture<'a>: Future<Output = ()> + 'a; | 4 | type DelayFuture<'a>: Future<Output = ()> + 'a; |
| 5 | 5 | ||
| 6 | /// Future that completes after now + millis | 6 | /// Future that completes after now + millis |
| 7 | fn delay_ms<'a>(&'a mut self, millis: u64) -> Self::DelayFuture<'a>; | 7 | fn delay_ms(&mut self, millis: u64) -> Self::DelayFuture<'_>; |
| 8 | 8 | ||
| 9 | /// Future that completes after now + micros | 9 | /// Future that completes after now + micros |
| 10 | fn delay_us<'a>(&'a mut self, micros: u64) -> Self::DelayFuture<'a>; | 10 | fn delay_us(&mut self, micros: u64) -> Self::DelayFuture<'_>; |
| 11 | } | 11 | } |
diff --git a/embassy-traits/src/flash.rs b/embassy-traits/src/flash.rs index 5e0a4e39f..94e11dbc5 100644 --- a/embassy-traits/src/flash.rs +++ b/embassy-traits/src/flash.rs | |||
| @@ -37,7 +37,7 @@ pub trait Flash { | |||
| 37 | /// Erases a single page from the flash device. | 37 | /// Erases a single page from the flash device. |
| 38 | /// | 38 | /// |
| 39 | /// address must be a multiple of self.erase_size(). | 39 | /// address must be a multiple of self.erase_size(). |
| 40 | fn erase<'a>(&'a mut self, address: usize) -> Self::ErasePageFuture<'a>; | 40 | fn erase(&mut self, address: usize) -> Self::ErasePageFuture<'_>; |
| 41 | 41 | ||
| 42 | /// Returns the total size, in bytes. | 42 | /// Returns the total size, in bytes. |
| 43 | /// This is not guaranteed to be a power of 2. | 43 | /// This is not guaranteed to be a power of 2. |
diff --git a/embassy-traits/src/gpio.rs b/embassy-traits/src/gpio.rs index 9fdb41f56..b8f31fc6c 100644 --- a/embassy-traits/src/gpio.rs +++ b/embassy-traits/src/gpio.rs | |||
| @@ -8,7 +8,7 @@ pub trait WaitForHigh { | |||
| 8 | /// | 8 | /// |
| 9 | /// If the pin is already high, the future completes immediately. | 9 | /// If the pin is already high, the future completes immediately. |
| 10 | /// Otherwise, it completes when it becomes high. | 10 | /// Otherwise, it completes when it becomes high. |
| 11 | fn wait_for_high<'a>(&'a mut self) -> Self::Future<'a>; | 11 | fn wait_for_high(&mut self) -> Self::Future<'_>; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | /// Wait for a pin to become low. | 14 | /// Wait for a pin to become low. |
| @@ -19,7 +19,7 @@ pub trait WaitForLow { | |||
| 19 | /// | 19 | /// |
| 20 | /// If the pin is already low, the future completes immediately. | 20 | /// If the pin is already low, the future completes immediately. |
| 21 | /// Otherwise, it completes when it becomes low. | 21 | /// Otherwise, it completes when it becomes low. |
| 22 | fn wait_for_low<'a>(&'a mut self) -> Self::Future<'a>; | 22 | fn wait_for_low(&mut self) -> Self::Future<'_>; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | /// Wait for a rising edge (transition from low to high) | 25 | /// Wait for a rising edge (transition from low to high) |
| @@ -27,7 +27,7 @@ pub trait WaitForRisingEdge { | |||
| 27 | type Future<'a>: Future<Output = ()> + 'a; | 27 | type Future<'a>: Future<Output = ()> + 'a; |
| 28 | 28 | ||
| 29 | /// Wait for a rising edge (transition from low to high) | 29 | /// Wait for a rising edge (transition from low to high) |
| 30 | fn wait_for_rising_edge<'a>(&'a mut self) -> Self::Future<'a>; | 30 | fn wait_for_rising_edge(&mut self) -> Self::Future<'_>; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | /// Wait for a falling edge (transition from high to low) | 33 | /// Wait for a falling edge (transition from high to low) |
| @@ -35,7 +35,7 @@ pub trait WaitForFallingEdge { | |||
| 35 | type Future<'a>: Future<Output = ()> + 'a; | 35 | type Future<'a>: Future<Output = ()> + 'a; |
| 36 | 36 | ||
| 37 | /// Wait for a falling edge (transition from high to low) | 37 | /// Wait for a falling edge (transition from high to low) |
| 38 | fn wait_for_falling_edge<'a>(&'a mut self) -> Self::Future<'a>; | 38 | fn wait_for_falling_edge(&'_ mut self) -> Self::Future<'_>; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | /// Wait for any edge (any transition, high to low or low to high) | 41 | /// Wait for any edge (any transition, high to low or low to high) |
| @@ -43,5 +43,5 @@ pub trait WaitForAnyEdge { | |||
| 43 | type Future<'a>: Future<Output = ()> + 'a; | 43 | type Future<'a>: Future<Output = ()> + 'a; |
| 44 | 44 | ||
| 45 | /// Wait for any edge (any transition, high to low or low to high) | 45 | /// Wait for any edge (any transition, high to low or low to high) |
| 46 | fn wait_for_any_edge<'a>(&'a mut self) -> Self::Future<'a>; | 46 | fn wait_for_any_edge(&mut self) -> Self::Future<'_>; |
| 47 | } | 47 | } |
diff --git a/embassy-traits/src/rng.rs b/embassy-traits/src/rng.rs index 3cc4b2a0b..ac4463ee6 100644 --- a/embassy-traits/src/rng.rs +++ b/embassy-traits/src/rng.rs | |||
| @@ -26,7 +26,7 @@ impl<T: Rng> Random<T> { | |||
| 26 | Self { rng } | 26 | Self { rng } |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | pub async fn next_u8<'a>(&'a mut self, range: u8) -> Result<u8, T::Error> { | 29 | pub async fn next_u8(&mut self, range: u8) -> Result<u8, T::Error> { |
| 30 | // Lemire's method | 30 | // Lemire's method |
| 31 | let t = (-(range as i8) % (range as i8)) as u8; | 31 | let t = (-(range as i8) % (range as i8)) as u8; |
| 32 | loop { | 32 | loop { |
| @@ -42,7 +42,7 @@ impl<T: Rng> Random<T> { | |||
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | pub async fn next_u16<'a>(&'a mut self, range: u16) -> Result<u16, T::Error> { | 45 | pub async fn next_u16(&mut self, range: u16) -> Result<u16, T::Error> { |
| 46 | // Lemire's method | 46 | // Lemire's method |
| 47 | let t = (-(range as i16) % (range as i16)) as u16; | 47 | let t = (-(range as i16) % (range as i16)) as u16; |
| 48 | loop { | 48 | loop { |
| @@ -58,7 +58,7 @@ impl<T: Rng> Random<T> { | |||
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | pub async fn next_u32<'a>(&'a mut self, range: u32) -> Result<u32, T::Error> { | 61 | pub async fn next_u32(&mut self, range: u32) -> Result<u32, T::Error> { |
| 62 | // Lemire's method | 62 | // Lemire's method |
| 63 | let t = (-(range as i32) % (range as i32)) as u32; | 63 | let t = (-(range as i32) % (range as i32)) as u32; |
| 64 | loop { | 64 | loop { |
diff --git a/embassy/src/channel/mpsc.rs b/embassy/src/channel/mpsc.rs index 9a57c0b19..12d85a52d 100644 --- a/embassy/src/channel/mpsc.rs +++ b/embassy/src/channel/mpsc.rs | |||
| @@ -130,7 +130,7 @@ where | |||
| 130 | /// closed by `recv` until they are all consumed. | 130 | /// closed by `recv` until they are all consumed. |
| 131 | /// | 131 | /// |
| 132 | /// [`close`]: Self::close | 132 | /// [`close`]: Self::close |
| 133 | pub fn recv<'m>(&'m mut self) -> RecvFuture<'m, M, T, N> { | 133 | pub fn recv(&mut self) -> RecvFuture<'_, M, T, N> { |
| 134 | RecvFuture { | 134 | RecvFuture { |
| 135 | channel: self.channel, | 135 | channel: self.channel, |
| 136 | } | 136 | } |
| @@ -469,7 +469,7 @@ impl<T, const N: usize> ChannelState<T, N> { | |||
| 469 | } | 469 | } |
| 470 | Err(message) => { | 470 | Err(message) => { |
| 471 | cx.into_iter() | 471 | cx.into_iter() |
| 472 | .for_each(|cx| self.set_senders_waker(&cx.waker())); | 472 | .for_each(|cx| self.set_senders_waker(cx.waker())); |
| 473 | Err(TrySendError::Full(message)) | 473 | Err(TrySendError::Full(message)) |
| 474 | } | 474 | } |
| 475 | } | 475 | } |
| @@ -487,7 +487,7 @@ impl<T, const N: usize> ChannelState<T, N> { | |||
| 487 | fn is_closed_with_context(&mut self, cx: Option<&mut Context<'_>>) -> bool { | 487 | fn is_closed_with_context(&mut self, cx: Option<&mut Context<'_>>) -> bool { |
| 488 | if self.closed { | 488 | if self.closed { |
| 489 | cx.into_iter() | 489 | cx.into_iter() |
| 490 | .for_each(|cx| self.set_senders_waker(&cx.waker())); | 490 | .for_each(|cx| self.set_senders_waker(cx.waker())); |
| 491 | true | 491 | true |
| 492 | } else { | 492 | } else { |
| 493 | false | 493 | false |
diff --git a/embassy/src/executor/raw/util.rs b/embassy/src/executor/raw/util.rs index ca15b6955..ed5822188 100644 --- a/embassy/src/executor/raw/util.rs +++ b/embassy/src/executor/raw/util.rs | |||
| @@ -12,6 +12,7 @@ impl<T> UninitCell<T> { | |||
| 12 | (*self.0.as_ptr()).get() | 12 | (*self.0.as_ptr()).get() |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | #[allow(clippy::mut_from_ref)] | ||
| 15 | pub unsafe fn as_mut(&self) -> &mut T { | 16 | pub unsafe fn as_mut(&self) -> &mut T { |
| 16 | &mut *self.as_mut_ptr() | 17 | &mut *self.as_mut_ptr() |
| 17 | } | 18 | } |
diff --git a/embassy/src/executor/spawner.rs b/embassy/src/executor/spawner.rs index 908e139ae..f06ac8a63 100644 --- a/embassy/src/executor/spawner.rs +++ b/embassy/src/executor/spawner.rs | |||
| @@ -95,7 +95,7 @@ impl Spawner { | |||
| 95 | /// fails. This is here to allow conditional use of `defmt::unwrap!` | 95 | /// fails. This is here to allow conditional use of `defmt::unwrap!` |
| 96 | /// without introducing a `defmt` feature in the `embassy_macros` package, | 96 | /// without introducing a `defmt` feature in the `embassy_macros` package, |
| 97 | /// which would require use of `-Z namespaced-features`. | 97 | /// which would require use of `-Z namespaced-features`. |
| 98 | pub fn must_spawn<F>(&self, token: SpawnToken<F>) -> () { | 98 | pub fn must_spawn<F>(&self, token: SpawnToken<F>) { |
| 99 | unwrap!(self.spawn(token)); | 99 | unwrap!(self.spawn(token)); |
| 100 | } | 100 | } |
| 101 | 101 | ||
diff --git a/embassy/src/io/util/read_exact.rs b/embassy/src/io/util/read_exact.rs index 80c9376d5..4eecba4cc 100644 --- a/embassy/src/io/util/read_exact.rs +++ b/embassy/src/io/util/read_exact.rs | |||
| @@ -39,7 +39,7 @@ impl<R: AsyncBufRead + ?Sized + Unpin> Future for ReadExact<'_, R> { | |||
| 39 | this.buf[..n].copy_from_slice(&buf[..n]); | 39 | this.buf[..n].copy_from_slice(&buf[..n]); |
| 40 | Pin::new(&mut this.reader).consume(n); | 40 | Pin::new(&mut this.reader).consume(n); |
| 41 | { | 41 | { |
| 42 | let (_, rest) = mem::replace(&mut this.buf, &mut []).split_at_mut(n); | 42 | let (_, rest) = mem::take(&mut this.buf).split_at_mut(n); |
| 43 | this.buf = rest; | 43 | this.buf = rest; |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
diff --git a/embassy/src/io/util/write_all.rs b/embassy/src/io/util/write_all.rs index 76b6ec092..8a7d9984c 100644 --- a/embassy/src/io/util/write_all.rs +++ b/embassy/src/io/util/write_all.rs | |||
| @@ -31,7 +31,7 @@ impl<W: AsyncWrite + ?Sized + Unpin> Future for WriteAll<'_, W> { | |||
| 31 | while !this.buf.is_empty() { | 31 | while !this.buf.is_empty() { |
| 32 | let n = ready!(Pin::new(&mut this.writer).poll_write(cx, this.buf))?; | 32 | let n = ready!(Pin::new(&mut this.writer).poll_write(cx, this.buf))?; |
| 33 | { | 33 | { |
| 34 | let (_, rest) = mem::replace(&mut this.buf, &[]).split_at(n); | 34 | let (_, rest) = mem::take(&mut this.buf).split_at(n); |
| 35 | this.buf = rest; | 35 | this.buf = rest; |
| 36 | } | 36 | } |
| 37 | if n == 0 { | 37 | if n == 0 { |
diff --git a/embassy/src/lib.rs b/embassy/src/lib.rs index 2eadefb08..a74d1a514 100644 --- a/embassy/src/lib.rs +++ b/embassy/src/lib.rs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #![feature(const_fn_trait_bound)] | 3 | #![feature(const_fn_trait_bound)] |
| 4 | #![feature(const_fn_fn_ptr_basics)] | 4 | #![feature(const_fn_fn_ptr_basics)] |
| 5 | #![feature(type_alias_impl_trait)] | 5 | #![feature(type_alias_impl_trait)] |
| 6 | #![allow(clippy::new_without_default)] | ||
| 6 | 7 | ||
| 7 | // This mod MUST go first, so that the others see its macros. | 8 | // This mod MUST go first, so that the others see its macros. |
| 8 | pub(crate) mod fmt; | 9 | pub(crate) mod fmt; |
diff --git a/embassy/src/time/delay.rs b/embassy/src/time/delay.rs index a46ee3a4f..13c2191f6 100644 --- a/embassy/src/time/delay.rs +++ b/embassy/src/time/delay.rs | |||
| @@ -13,10 +13,10 @@ pub struct Delay; | |||
| 13 | impl crate::traits::delay::Delay for Delay { | 13 | impl crate::traits::delay::Delay for Delay { |
| 14 | type DelayFuture<'a> = impl Future<Output = ()> + 'a; | 14 | type DelayFuture<'a> = impl Future<Output = ()> + 'a; |
| 15 | 15 | ||
| 16 | fn delay_ms<'a>(&'a mut self, millis: u64) -> Self::DelayFuture<'a> { | 16 | fn delay_ms(&mut self, millis: u64) -> Self::DelayFuture<'_> { |
| 17 | Timer::after(Duration::from_millis(millis)) | 17 | Timer::after(Duration::from_millis(millis)) |
| 18 | } | 18 | } |
| 19 | fn delay_us<'a>(&'a mut self, micros: u64) -> Self::DelayFuture<'a> { | 19 | fn delay_us(&mut self, micros: u64) -> Self::DelayFuture<'_> { |
| 20 | Timer::after(Duration::from_micros(micros)) | 20 | Timer::after(Duration::from_micros(micros)) |
| 21 | } | 21 | } |
| 22 | } | 22 | } |
diff --git a/embassy/src/util/forever.rs b/embassy/src/util/forever.rs index 0432fa51e..e367d2643 100644 --- a/embassy/src/util/forever.rs +++ b/embassy/src/util/forever.rs | |||
| @@ -45,6 +45,7 @@ impl<T> Forever<T> { | |||
| 45 | /// | 45 | /// |
| 46 | /// Returns a mutable reference to the stored value. | 46 | /// Returns a mutable reference to the stored value. |
| 47 | #[inline(always)] | 47 | #[inline(always)] |
| 48 | #[allow(clippy::mut_from_ref)] | ||
| 48 | pub fn put(&'static self, val: T) -> &'static mut T { | 49 | pub fn put(&'static self, val: T) -> &'static mut T { |
| 49 | if self | 50 | if self |
| 50 | .used | 51 | .used |
| @@ -63,6 +64,7 @@ impl<T> Forever<T> { | |||
| 63 | } | 64 | } |
| 64 | 65 | ||
| 65 | #[inline(always)] | 66 | #[inline(always)] |
| 67 | #[allow(clippy::mut_from_ref)] | ||
| 66 | pub fn put_with(&'static self, val: impl FnOnce() -> T) -> &'static mut T { | 68 | pub fn put_with(&'static self, val: impl FnOnce() -> T) -> &'static mut T { |
| 67 | if self | 69 | if self |
| 68 | .used | 70 | .used |
| @@ -81,6 +83,7 @@ impl<T> Forever<T> { | |||
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | #[inline(always)] | 85 | #[inline(always)] |
| 86 | #[allow(clippy::mut_from_ref)] | ||
| 84 | pub unsafe fn steal(&'static self) -> &'static mut T { | 87 | pub unsafe fn steal(&'static self) -> &'static mut T { |
| 85 | let p = self.t.get(); | 88 | let p = self.t.get(); |
| 86 | let p = (&mut *p).as_mut_ptr(); | 89 | let p = (&mut *p).as_mut_ptr(); |
