Skip to content

Commit b0688eb

Browse files
committed
chore: deny let_underscore_drop
I'm curious for opinions on this. I stubbed my toe recently on: ``` let _ = span.enter(); ``` Which does not enter the span for the remainder of the function (it immediately drops the span). There is already a by-default-deny lint for `let _ = lock()` but no such lint for other guard-like things: - [`tracing::Span::enter()`](https://docs.rs/tracing/latest/tracing/struct.Span.html#method.enter) - [`xshell::Shell::push_dir`](https://docs.rs/xshell/latest/xshell/struct.Shell.html#method.push_dir) Signed-off-by: Daniel King <[email protected]>
1 parent 369defb commit b0688eb

File tree

10 files changed

+25
-21
lines changed

10 files changed

+25
-21
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ package = "getrandom"
264264
version = "0.3.1"
265265

266266
[workspace.lints.rust]
267+
let_underscore_drop = "deny"
267268
macro_use_extern_crate = "deny"
268269
redundant_lifetimes = "deny"
269270
unsafe_op_in_unsafe_fn = "deny"

bench-vortex/src/clickbench/clickbench_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl Flavor {
399399
let pool = rayon::ThreadPoolBuilder::new()
400400
.thread_name(|i| format!("clickbench download {i}"))
401401
.build()?;
402-
let _ = pool.install(|| (0_u32..100).into_par_iter().map(|idx| {
402+
let _unused = pool.install(|| (0_u32..100).into_par_iter().map(|idx| {
403403
let output_path = basepath.join(Format::Parquet.name()).join(format!("hits_{idx}.parquet"));
404404
idempotent(&output_path, |output_path| {
405405
info!("Downloading file {idx}");

vortex-cxx/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub(crate) static RUNTIME: LazyLock<CurrentThreadRuntime> =
2626
LazyLock::new(CurrentThreadRuntime::new);
2727

2828
#[cxx::bridge(namespace = "vortex::ffi")]
29+
#[allow(let_underscore_drop)]
2930
mod ffi {
3031
extern "Rust" {
3132
type DType;

vortex-duckdb/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn download_duckdb_lib_archive() -> Result<PathBuf, Box<dyn std::error::Error>>
4444
let archive_path = duckdb_dir.join(&archive_name);
4545

4646
// Recreate the duckdb directory
47-
let _ = fs::remove_dir_all(&duckdb_dir);
47+
drop(fs::remove_dir_all(&duckdb_dir));
4848
fs::create_dir_all(&duckdb_dir)?;
4949

5050
if !archive_path.exists() {
@@ -192,7 +192,7 @@ fn build_duckdb(duckdb_source_root: &Path) -> Result<PathBuf, Box<dyn std::error
192192
let target_dir = manifest_dir.parent().unwrap().join("target");
193193
let duckdb_library_dir = target_dir.join("duckdb-lib");
194194

195-
let _ = fs::remove_dir_all(&duckdb_library_dir);
195+
drop(fs::remove_dir_all(&duckdb_library_dir));
196196
fs::create_dir_all(&duckdb_library_dir)?;
197197

198198
// Copy .dylib and .so files (macOS and Linux).
@@ -223,7 +223,7 @@ fn main() {
223223
// Download, extract and symlink DuckDB source code.
224224
let zip_source_path = download_duckdb_source_archive().unwrap();
225225
let extracted_source_path = extract_duckdb_source(zip_source_path).unwrap();
226-
let _ = fs::remove_dir_all(&duckdb_repo);
226+
drop(fs::remove_dir_all(&duckdb_repo));
227227
std::os::unix::fs::symlink(&extracted_source_path, &duckdb_repo).unwrap();
228228

229229
let library_path =

vortex-duckdb/src/duckdb/object_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{cpp, lifetime_wrapper};
1212
unsafe extern "C-unwind" fn rust_box_deleter<T>(ptr: *mut c_void) {
1313
if !ptr.is_null() {
1414
unsafe {
15-
let _ = Box::from_raw(ptr as *mut T);
15+
drop(Box::from_raw(ptr as *mut T));
1616
}
1717
}
1818
}

vortex-gpu/src/jit/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn create_run_jit_kernel(
5757
.record_event(Some(CU_EVENT_DEFAULT))
5858
.ok()
5959
.vortex_expect("Failed to record event");
60-
let _ = unsafe { launch_builder.launch(launch_config) };
60+
drop(unsafe { launch_builder.launch(launch_config) });
6161
ctx.synchronize()
6262
.map_err(|e| vortex_err!("Failed to synchronize: {e}"))?;
6363
let end = stream

vortex-io/src/file/read/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl Drop for ReadFuture {
124124
fn drop(&mut self) {
125125
// When the FileHandle is dropped, we can send a shutdown event to the I/O stream.
126126
// If the I/O stream has already been dropped, this will fail silently.
127-
let _ = self.events.unbounded_send(ReadEvent::Dropped(self.id));
127+
drop(self.events.unbounded_send(ReadEvent::Dropped(self.id)));
128128
}
129129
}
130130

vortex-io/src/runtime/handle.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Handle {
6767
let abort_handle = self.runtime().spawn(
6868
async move {
6969
// Task::detach allows the receiver to be dropped, so we ignore send errors.
70-
let _ = send.send(f.await);
70+
drop(send.send(f.await));
7171
}
7272
.boxed(),
7373
);
@@ -106,7 +106,7 @@ impl Handle {
106106
// Optimistically avoid the work if the result won't be used.
107107
if !send.is_closed() {
108108
// Task::detach allows the receiver to be dropped, so we ignore send errors.
109-
let _ = send.send(f());
109+
drop(send.send(f()));
110110
}
111111
}));
112112
Task {
@@ -126,7 +126,7 @@ impl Handle {
126126
// Optimistically avoid the work if the result won't be used.
127127
if !send.is_closed() {
128128
// Task::detach allows the receiver to be dropped, so we ignore send errors.
129-
let _ = send.send(f());
129+
drop(send.send(f()));
130130
}
131131
}));
132132
Task {

vortex-io/src/runtime/single.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ impl Sender {
5656
while let Ok(spawn) = scheduling_recv.as_async().recv().await {
5757
if let Some(local) = weak_local2.upgrade() {
5858
// Ignore send errors since it means the caller immediately detached.
59-
let _ = spawn
60-
.task_callback
61-
.send(SmolAbortHandle::new_handle(local.spawn(spawn.future)));
59+
drop(
60+
spawn
61+
.task_callback
62+
.send(SmolAbortHandle::new_handle(local.spawn(spawn.future))),
63+
);
6264
}
6365
}
6466
})
@@ -72,9 +74,9 @@ impl Sender {
7274
if let Some(local) = weak_local2.upgrade() {
7375
let work = spawn.sync;
7476
// Ignore send errors since it means the caller immediately detached.
75-
let _ = spawn.task_callback.send(SmolAbortHandle::new_handle(
77+
drop(spawn.task_callback.send(SmolAbortHandle::new_handle(
7678
local.spawn(async move { work() }),
77-
));
79+
)));
7880
}
7981
}
8082
})
@@ -88,9 +90,9 @@ impl Sender {
8890
if let Some(local) = weak_local2.upgrade() {
8991
let work = spawn.sync;
9092
// Ignore send errors since it means the caller immediately detached.
91-
let _ = spawn.task_callback.send(SmolAbortHandle::new_handle(
93+
drop(spawn.task_callback.send(SmolAbortHandle::new_handle(
9294
local.spawn(async move { work() }),
93-
));
95+
)));
9496
}
9597
}
9698
})

vortex-layout/src/layouts/dict/writer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl Stream for DictionaryTransformer {
370370
// Receiver dropped, close this group
371371
self.active_codes_tx = None;
372372
if let Some(values_tx) = self.active_values_tx.take() {
373-
let _ = values_tx.send(Err(vortex_err!("values receiver dropped")));
373+
drop(values_tx.send(Err(vortex_err!("values receiver dropped"))));
374374
}
375375
}
376376
Poll::Pending => {
@@ -423,14 +423,14 @@ impl Stream for DictionaryTransformer {
423423
Poll::Ready(Some(Ok(DictionaryChunk::Values(values)))) => {
424424
// Complete the current group
425425
if let Some(values_tx) = self.active_values_tx.take() {
426-
let _ = values_tx.send(Ok(values));
426+
drop(values_tx.send(Ok(values)));
427427
}
428428
self.active_codes_tx = None; // Close codes stream
429429
}
430430
Poll::Ready(Some(Err(e))) => {
431431
// Send error to active channels if any
432432
if let Some(values_tx) = self.active_values_tx.take() {
433-
let _ = values_tx.send(Err(e));
433+
drop(values_tx.send(Err(e)));
434434
}
435435
self.active_codes_tx = None;
436436
// And terminate the stream
@@ -439,7 +439,7 @@ impl Stream for DictionaryTransformer {
439439
Poll::Ready(None) => {
440440
// Handle any incomplete group
441441
if let Some(values_tx) = self.active_values_tx.take() {
442-
let _ = values_tx.send(Err(vortex_err!("Incomplete dictionary group")));
442+
drop(values_tx.send(Err(vortex_err!("Incomplete dictionary group"))));
443443
}
444444
self.active_codes_tx = None;
445445
return Poll::Ready(None);

0 commit comments

Comments
 (0)