Code
fn main() {
let foo = std::ptr::null_mut::<()>();
std::thread::spawn(move || {
unsafe { foo.read(); }
});
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0277]: `*mut ()` cannot be sent between threads safely
--> src/main.rs:3:24
|
3 | std::thread::spawn(move || {
| ------------------ ^------
| | |
| _____|__________________within this `{closure@src/main.rs:3:24: 3:31}`
| | |
| | required by a bound introduced by this call
4 | | unsafe { foo.read(); }
5 | | });
| |_____^ `*mut ()` cannot be sent between threads safely
|
= help: within `{closure@src/main.rs:3:24: 3:31}`, the trait `Send` is not implemented for `*mut ()`
note: required because it's used within this closure
--> src/main.rs:3:24
|
3 | std::thread::spawn(move || {
| ^^^^^^^
note: required by a bound in `spawn`
--> /playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/functions.rs:128:8
|
125 | pub fn spawn<F, T>(f: F) -> JoinHandle<T>
| ----- required by a bound in this function
...
128 | F: Send + 'static,
| ^^^^ required by this bound in `spawn`
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Desired output
...
note: required because `foo` is used within this closure
...
Rationale and extra context
While it is obvious in this context, it is not obvious when a closure captures many variables.
Other cases
Rust Version
Playground in 1.97.1 as well as 1.100.0-nightly (2026-08-18 e71c0f1e3395b10a8c33)
Anything else?
I couldn't find an existing issue for this. It might exist but GitHub search sucks.
Code
Current output
Desired output
... note: required because `foo` is used within this closure ...Rationale and extra context
While it is obvious in this context, it is not obvious when a closure captures many variables.
Other cases
Rust Version
Playground in 1.97.1 as well as 1.100.0-nightly (2026-08-18 e71c0f1e3395b10a8c33)Anything else?
I couldn't find an existing issue for this. It might exist but GitHub search sucks.