From 758436cc28a6d1447f89ccffe4224ce6b4eb2fd9 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sat, 29 Aug 2026 23:48:15 +0200 Subject: [PATCH] Keep the runner's borrow alive as long as the connection it reads The first compile this branch had. One borrow error, in the four-thread contention test: the `Runner` was the block's tail expression, and a tail's temporaries are dropped after the block's locals, so it outlived the `conn` it borrowed. Bound to a local, with the ordering rule written down beside it -- it is exactly the shape someone tidies back. Everything else stood: clippy clean at -D warnings, and all 18 runner tests pass, including the four-thread four-connection claim and the `UPDATE ... RETURNING` rewrite the author flagged as the riskiest line in the diff. Co-Authored-By: Claude Opus 5 (1M context) --- core/dr-catalog/src/runner.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/dr-catalog/src/runner.rs b/core/dr-catalog/src/runner.rs index b47f850..d0d171f 100644 --- a/core/dr-catalog/src/runner.rs +++ b/core/dr-catalog/src/runner.rs @@ -853,11 +853,16 @@ mod tests { let seen = seen.clone(); threads.push(std::thread::spawn(move || { let conn = open(&path); - Runner::new(&conn) + // Bound to a local rather than left as the block's tail: the + // `Runner` borrows `conn`, and a tail expression's temporaries + // are dropped *after* the block's locals, so the borrow would + // outlive what it borrows. + let completed = Runner::new(&conn) .with(recording(vec![JobKind::Thumbnail], seen)) .drain_all(0) .unwrap() - .completed + .completed; + completed })); }