rust/library
Yuki Okushi 05a2366e82
Rollup merge of #82751 - RalfJung:offset_from, r=dtolnay
improve offset_from docs

`@thomcc` pointed out that the current docs leave it kind of unclear how one can satisfy the "no wrapping around `isize` or the address space" requirement of `offset_from`, so make the docs clearer about that.

FWIW, I don't think I entirely agree with that second paragraph about large objects (that I left mostly unchanged here). LLVM, to my knowledge, fundamentally assumes that all allocations fit into an `isize::MAX`. So in that sense creating a larger allocation is simply UB. I would expect a guarantee that Rust heap allocation methods will never return allocations larger than `isize::MAX` (or rather, Rust heap allocation methods should require that the `Layout` is no larger than `isize::MAX`). However, I cannot find any such requirement documented currently. Large allocations are not mentioned at all in the allocator docs, which is quite surprising -- even if we say that such allocations are not insta-UB (which I think is incompatible with LLVM), they are still extremely footgunny since `ptr::offset`/`ptr::add` do not support offsetting by more than `isize::MAX` bytes.

Furthermore, the allocator docs don't even say anything about allocations wrapping around the address space. But that is certainly something allocators must ensure never happens; we cannot expect clients to defend against this.

Cc `@rust-lang/wg-allocators`
2021-03-07 10:41:16 +09:00
..
alloc Rollup merge of #82764 - m-ou-se:map-try-insert, r=Amanieu 2021-03-05 10:57:22 +01:00
backtrace@af078ecc0b
core Rollup merge of #82751 - RalfJung:offset_from, r=dtolnay 2021-03-07 10:41:16 +09:00
panic_abort slightly more typed interface to panic implementation 2020-12-21 13:37:59 +01:00
panic_unwind Revert stabilizing integer::BITS. 2021-02-03 22:23:58 +01:00
proc_macro impl PartialEq<Punct> for char; symmetry for #78636 2021-02-19 17:28:19 -08:00
profiler_builtins Build newly added InstrProfilingVersionVar.c file 2021-03-01 23:35:35 +01:00
rtstartup Bump bootstrap compiler to 1.50 beta 2020-12-30 09:27:19 -05:00
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Rollup merge of #82770 - m-ou-se:assert-match, r=joshtriplett 2021-03-05 10:57:23 +01:00
stdarch@9c732a56f6
term Allow/fix non_fmt_panic in tests. 2021-02-03 23:15:45 +01:00
test Auto merge of #82350 - ehuss:test-chapter, r=jyn514 2021-02-28 09:18:27 +00:00
unwind Change built-in kernel targets to be os = none throughout 2021-03-01 12:46:25 -05:00