Hi all,
I have the following code that triggers Clippy's unit-arg lint and I have absolutely no idea why
. Can anybody explain this to me?
The code:
/// Observe RSSI values.
#[tracing::instrument(level = "info", err)]
pub fn monitor_rssi(update_tx: Sender<Update>) -> Result<()> {
tracing::debug!("spawn btmon");
let (btmon, btlines) = launch_btmon()?;
thread::spawn(move || {
// fn inner_loop(Child, impl Iterator, Sender<Update>) -> Result<()>
if let Err(error) = inner_loop(btmon, btlines, update_tx) {
tracing::error!(%error, "RSSI monitor failed!");
}
});
Ok(())
}
The warning emitted by Clippy:
error: passing a unit value to a function
--> src/bluetooth/rssi.rs:155:62
|
155 | pub fn monitor_rssi(update_tx: Sender<Update>) -> Result<()> {
| ______________________________________________________________^
156 | | tracing::debug!("spawn btmon");
157 | | let (btmon, btlines) = launch_btmon()?;
158 | |
... |
165 | | Ok(())
166 | | }
| |_^
|
= note: `-D clippy::unit-arg` implied by `-D warnings`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
help: move the expression in front of the call and replace it with the unit literal `()`
|
155 | pub fn monitor_rssi(update_tx: Sender<Update>) -> Result<()> {
156 | {
157 | tracing::debug!("spawn btmon");
158 | let (btmon, btlines) = launch_btmon()?;
159 |
160 | thread::spawn(move || {
...
I know I can switch Clippy of with `#[allow(clippy::unit-arg)]. I'm just curious why the lint is triggered.