From d37a9499717d171db514fb03bdc3cd989c7c4655 Mon Sep 17 00:00:00 2001 From: yvt Date: Sun, 14 Aug 2022 11:06:38 +0900 Subject: [PATCH] refactor(test_runner): address the `explicit_auto_deref` clippy lint --- src/r3_test_runner/src/main.rs | 1 + src/r3_test_runner/src/selection.rs | 2 +- src/r3_test_runner/src/targets/kflash.rs | 6 +++++- src/r3_test_runner/src/targets/probe_rs.rs | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/r3_test_runner/src/main.rs b/src/r3_test_runner/src/main.rs index 7d11dad709..3c9eb6a049 100644 --- a/src/r3_test_runner/src/main.rs +++ b/src/r3_test_runner/src/main.rs @@ -1,6 +1,7 @@ #![feature(exhaustive_patterns)] #![feature(generic_arg_infer)] #![feature(must_not_suspend)] // `must_not_suspend` lint +#![feature(lint_reasons)] #![feature(decl_macro)] // `macro` #![feature(pin_macro)] // `core::pin::pin!` #![feature(let_else)] // `let ... = ... else { ... }` diff --git a/src/r3_test_runner/src/selection.rs b/src/r3_test_runner/src/selection.rs index 05fde06556..2e3db7801c 100644 --- a/src/r3_test_runner/src/selection.rs +++ b/src/r3_test_runner/src/selection.rs @@ -68,7 +68,7 @@ fn all_test_runs(test_source: &TestSource) -> impl Iterator> test_source .driver_kernel_tests .iter() - .map(|s| TestCase::DriverKernelTest(&**s)), + .map(|s| TestCase::DriverKernelTest(s)), ); iproduct!(cases, &[false, true]).map(|(case, &cpu_lock_by_basepri)| TestRun { diff --git a/src/r3_test_runner/src/targets/kflash.rs b/src/r3_test_runner/src/targets/kflash.rs index 9ece132539..231874e205 100644 --- a/src/r3_test_runner/src/targets/kflash.rs +++ b/src/r3_test_runner/src/targets/kflash.rs @@ -199,7 +199,11 @@ impl DebugProbe for KflashDebugProbe { let serial_m = Mutex::new(&mut self.serial); let isp_boot_cmds = self.isp_boot_cmds; retry_on_fail(|| async { - maix_enter_isp_mode(*serial_m.try_lock().unwrap(), isp_boot_cmds).await + // Holding the `LockGuard` across a suspend point is okay because + // `Mutex::lock` is never called for this mutex. (It's practically + // a thread-safe `RefCell`.) + #[allow(must_not_suspend)] + maix_enter_isp_mode(&mut serial_m.try_lock().unwrap(), isp_boot_cmds).await }) .await .map_err(RunError::Communication)?; diff --git a/src/r3_test_runner/src/targets/probe_rs.rs b/src/r3_test_runner/src/targets/probe_rs.rs index 732a1d4c20..3265359883 100644 --- a/src/r3_test_runner/src/targets/probe_rs.rs +++ b/src/r3_test_runner/src/targets/probe_rs.rs @@ -111,7 +111,7 @@ impl DebugProbe for ProbeRsDebugProbe { let exe2 = exe.clone(); let mut session = spawn_blocking(move || { probe_rs::flashing::download_file( - &mut *session, + &mut session, &exe2, probe_rs::flashing::Format::Elf, )?; @@ -368,6 +368,7 @@ impl AsyncBufRead for ReadRtt { let num_read_bytes = Self::read_inner( &mut session, &mut rtt, + #[expect(clippy::explicit_auto_deref)] // false positive &mut *buf, halt_on_access, )?;