Files
Jacob Pratt beeaa7ab0b Rollup merge of #158782 - Mark-Simulacrum:expose-no-threads, r=Urgau
Add and use cfg(target_has_threads) to enforce no_thread impl usage

The standard library has fallback code for targets without threads (e.g., using a Cell-based Mutex and similar). Today there's no enforcement in std that those targets truly don't have threads which makes that code potentially unsound. This will let us add a static assertion that the target spec agrees that the target is non-threaded. Getting the target spec wrong is already unsound (e.g., LLVM can make use of that) so it's a reasonable source of truth. This pulls in the atomics target feature into the target code and makes the field itself private to encourage going via the method.

For now the cfg is added as unstable but if we have a use case for user code to use this, happy to cut a tracking issue and make it a regular unstable feature.

Setting a compiler reviewer since the std changes are pretty trivial, and I think anyone can review those reasonably.

cc rust-lang/rust#156366 which prompted looking into this

r? compiler
2026-07-06 04:33:09 -04:00
..