# Rust: error[E0373]: closure may outlive the current function, but it borrows `v`, which is owned by the current function

**Code:** `E0373: closure may outlive the current function` · **Category:** Rust · **Seen on:** Rust

A closure borrowing a local is passed somewhere that may outlive it (thread::spawn, tokio::spawn, returned closures).

## Meaning

Use `move` so the closure takes ownership: `thread::spawn(move || {...})`. If you need the value afterwards, clone before moving, or share via `Arc`. For scoped use `thread::scope(|s| ...)` which allows borrowing.

## Common causes

- `thread::spawn(|| use(v))` without `move`
- `tokio::spawn(async { ... })` borrowing locals
- Returning a closure that borrows locals
- Storing closures in structs
- Callbacks outliving the function

## Quick fix

1. Add `move` to the closure
2. Clone data first or wrap in `Arc`
3. Use `std::thread::scope` to borrow

## Detailed fix by platform

### Rust

1. `let v2 = v.clone(); thread::spawn(move
2. println!("{v2:?}));`

## How to diagnose

1. **Closure** — Borrowing?
2. **Lifetime** — Outlives the function?
3. **Fix** — move/Arc/scope?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/rust/e0373-closure-may-outlive-the-current-function)
