// A compiler experiment, expected to be refused: the same crossing as
// `../crossing`, through a Rust function that claims its value is safe to send
// to another thread (`unsafe impl Send`) when it is not.
//
// cd examples/foreign-runtime/smuggled
// nikaia build
// error[NK2502]: `handle` may not cross a thread, and
// `hyper_shim::across_a_thread_unchecked` may put it on one
//
// The first build fetches `hyper` and `tokio` from crates.io.
//
// It checks that the false claim in Rust does not get the value through. The
// refusal rests on the crate's description in `contracts/`, which a person
// wrote and reviews. That is not a proof of safety: a wrong description would
// let it through.
fn main() {
let handle = hyper_shim::local_handle("not Send")
let crossed = hyper_shim::across_a_thread_unchecked(handle)
println(f"crossed: {crossed}")
}
The file itself · all the examples