Skip to content

Commit

Permalink
refactor(test_runner): address the drop_non_drop clippy lint
Browse files Browse the repository at this point in the history
This `drop` call is intended to cut short the borrow `'a` maintained by
a reference-containing `Mutex<&'a mut _>`, but actually it's unnecessary
because `Mutex`'s contained data (`&'a mut _`) is not subject to [drop
check][1], hence the borrow is allowed to expire before the containing
`Mutex` is dropped.

As for the `drop_non_drop` lint, I would say it's a false-positive
because not every target supported by `std` has a trivial destructor for
`Mutex`. This lint started to trigger only recently because
[rust-lang/rust#95035][2] replaced the `Mutex` implementation with a
futex-based one on Linux.

[1]: https://doc.rust-lang.org/nomicon/dropck.html
[2]: rust-lang/rust#95035
  • Loading branch information
yvt committed Aug 14, 2022
1 parent 159ab9b commit bb6f6d9
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/r3_test_runner/src/targets/kflash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ impl DebugProbe for KflashDebugProbe {
})
.await
.map_err(RunError::Communication)?;
drop(serial_m);

// Program the executable image
for (i, region) in regions.iter().enumerate() {
Expand Down

0 comments on commit bb6f6d9

Please sign in to comment.