Obviously this is unstructured speculation, but you can model the various sub-modules of std as APIs (think std::thread which has spawn(), current() etc.) with associated types (Thread, JoinHandle etc.).
A trait based model would have a std::thread “trait” that specifies that API with some number of impls for various platforms. So far, so obvious, I think this is what everyone is picturing in the last few comments.
If we allow some std-only magic (or a new language feature) we could implement the std::thread module’s API through the trait statically (so the code says std::thread::spawn() but that is compiled down to <std::linux::x86_64::gnu::thread::Impl as std::thread::ModTrait>::spawn() (i.e. the existing API stays usable, but is backed by a statically-dispatched, selected-at-compile-time implementation, that depends on platform and/or, as @matthieum suggests mocking or scope attributes).
Shouldn’t slow down compilation speeds, since all the translations are fixed for a single compile, and won’t slow down the generated code, since the function calls are all static-dispatch.
Wild speculation begins here Expose all (not just std) module APIs through a trait rather than unbound functions so any module can be swapped out for specialisation or testing purposes. End wild speculation