Note infinite-precision in std::ptr Allocation docs#155372
Note infinite-precision in std::ptr Allocation docs#155372iximeow wants to merge 2 commits intorust-lang:mainfrom
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This was noted off-handedly in the PR discussion where this section was reworked. It seems worthwhile to note explicitly that an allocation's base and size are not "usize" or "isize" but infinitely-wide types where `<= usize::MAX` cannot be trivially assumed.
0179fce to
61da6d3
Compare
|
thank u rustbot |
|
I don't know what you mean by infinite-precision. I'm not sure we've ever used that terminology with regard to provenance, is there another way to express what you mean? If someone does call |
|
this is more about "can an allocation wrap across the end of the address space" than anything about provenance; I only mention infinite-precision refers to
couldn't there be a ZST there? (though also since |
|
I see. I think it would be less confusing to add a note that none of the arithmetic wraps. At least it would have been easier for my brain because that's a term we already use in this space. |
|
I've adjusted the wording a bit differently, any time I tried to describe it as non-wrapping arithmetic it felt a bit hamfisted.. but in the "As a consequence ..." section we've already described the idea that sums do not wrap the address space. so I think it reads better to pull that up to talk about does this read better to you as well? |
This was noted off-handedly in #116675 where this section was reworked. It seems worthwhile to note explicitly that an allocation's base and size are not "usize" or "isize" but infinitely-wide types where
<= usize::MAXcannot be trivially assumed.I got here trying to figure out if/why
with_exposed_provenance::<(u8, u8)>(usize::MAX)returns an invalid*const T. eitherbase + size <= usize::MAXis trivially true, or there's an assumption of wider-than-usize arithmetic and the answer is "it's invalid". seems like the latter, thank goodness! this was discussed in a few places in #116675 (this other comment for example) but ended up left to a careful reader in the landed docs.