Commit 118ac6b
committed
Transfer driver: bound async closures with Pin<Box<dyn Future + Send>>
- `drive_transfer_serial_async` previously used `AsyncFnMut(...)` bounds. The driver's own `#[tokio::test]`s passed, but production callers compile inside `tokio::spawn` and fail the Send check: `AsyncFnMut`'s HRTB-bound `CallRefFuture<'a>` is not provably Send for all `'a` when the closure body captures `&Arc<...>` or similar refs (rust-lang/rust#100013-class).
- Switched the three closure bounds to `for<'a> FnMut(...) -> Pin<Box<dyn Future<...> + Send + 'a>>`. `+ Send` on the boxed trait object is what makes the driver's awaiting-this-future state Send. Driver loop body unchanged (each closure call is still `.await`-ed in sequence).
- Migrated all 18 async tests from `async ||` syntax to explicit `Box::pin(async move { ... })`. Bodies unchanged; only the closure wrappers changed. Added 3 type aliases (`FetchFut`, `ResolveFut`, `TransferFut`) so the test closures stay readable.
- Added `driver_future_is_send_across_spawn` regression test: runs the driver call through an explicit inner `tokio::spawn` boundary that captures an outer `Arc` by ref, which is the smallest setup that reproduced the original failure ("Send is not general enough"). Compiles and passes under the new bound.
- Updated the driver's doc comment and the colocated `CLAUDE.md` to capture the rationale.
- 30 tests pass (29 existing + 1 new). No production callers touched.1 parent b6833e2 commit 118ac6b
3 files changed
Lines changed: 290 additions & 126 deletions
File tree
- apps/desktop/src-tauri/src/file_system/write_operations
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
| |||
Lines changed: 30 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
| 107 | + | |
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
| |||
521 | 523 | | |
522 | 524 | | |
523 | 525 | | |
524 | | - | |
| 526 | + | |
525 | 527 | | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
533 | 544 | | |
534 | 545 | | |
535 | 546 | | |
| |||
551 | 562 | | |
552 | 563 | | |
553 | 564 | | |
554 | | - | |
555 | | - | |
556 | | - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
557 | 576 | | |
558 | 577 | | |
559 | 578 | | |
| |||
0 commit comments