rust/library/std
Dylan DPC 4bd40186db
Rollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC
explain how to turn integers into fn ptrs

(with an intermediate raw ptr, not a direct transmute)
Direct int2ptr transmute, under the semantics I am imagining, will produce a ptr with "invalid" provenance that is invalid to deref or call. We cannot give it the same semantics as int2ptr casts since those do [something complicated](https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html).

To my great surprise, that is already what the example in the `transmute` docs does. :)  I still added a comment to say that that part is important, and I added a section explicitly talking about this to the `fn()` type docs.

With https://github.com/rust-lang/miri/pull/2151, Miri will start complaining about direct int-to-fnptr transmutes (in the sense that it is UB to call the resulting pointer).
2022-05-24 15:58:26 +02:00
..
benches
primitive_docs
src Rollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC 2022-05-24 15:58:26 +02:00
tests Fold aarch64 feature +fp into +neon 2022-03-22 15:14:33 -07:00
build.rs
Cargo.toml Update libc dependency of std to 0.2.126 2022-05-21 00:02:20 +02:00