Commit ae08c58
authored
Rollup merge of rust-lang#126213 - zachs18:atomicbool-u8-i8-from-ptr-alignment, r=Nilstrieb
Update docs for AtomicBool/U8/I8 with regard to alignment
Fixes rust-lang#126084.
Since `AtomicBool`/`AtomicU8`/`AtomicI8` are guaranteed to have size == 1, and Rust guarantees that `size % align == 0`, they also must have alignment equal to 1, so some current docs are contradictory/confusing when describing their alignment requirements.
Specifically:
* Fix `AtomicBool::from_ptr` claiming that `align_of::<AtomicBool>() > align_of::<bool>()` on some platforms. (same for `AtomicU8::from_ptr`/`AtomicI8::from_ptr`)
* Explicitly state that `AtomicU8`/`AtomicI8` have the same alignment as `u8`/`i8` (in addition to size and bit validity)
* (internal) Change the `if_not_8_bit` macro to be `if_8_bit` and to allow an "if-else"-like structure, instead of just "if"-like.
---
I opted to leave the "`ptr` must be aligned" wording in `from_ptr`'s docs and just clarify that it is always satsified, instead of just removing the wording entirely. If that is instead preferred I can do that.1 file changed
+33
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
446 | | - | |
447 | | - | |
| 446 | + | |
| 447 | + | |
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| |||
2091 | 2091 | | |
2092 | 2092 | | |
2093 | 2093 | | |
2094 | | - | |
2095 | | - | |
2096 | | - | |
2097 | | - | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
2098 | 2098 | | |
2099 | 2099 | | |
2100 | 2100 | | |
| |||
2116 | 2116 | | |
2117 | 2117 | | |
2118 | 2118 | | |
2119 | | - | |
2120 | | - | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
2121 | 2126 | | |
2122 | 2127 | | |
2123 | | - | |
| 2128 | + | |
2124 | 2129 | | |
2125 | | - | |
| 2130 | + | |
2126 | 2131 | | |
2127 | 2132 | | |
2128 | 2133 | | |
2129 | | - | |
| 2134 | + | |
2130 | 2135 | | |
| 2136 | + | |
2131 | 2137 | | |
2132 | 2138 | | |
2133 | 2139 | | |
| |||
2220 | 2226 | | |
2221 | 2227 | | |
2222 | 2228 | | |
2223 | | - | |
2224 | | - | |
2225 | | - | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
2226 | 2242 | | |
2227 | 2243 | | |
2228 | 2244 | | |
| |||
2261 | 2277 | | |
2262 | 2278 | | |
2263 | 2279 | | |
2264 | | - | |
| 2280 | + | |
2265 | 2281 | | |
2266 | | - | |
| 2282 | + | |
2267 | 2283 | | |
2268 | 2284 | | |
2269 | | - | |
| 2285 | + | |
2270 | 2286 | | |
2271 | 2287 | | |
2272 | 2288 | | |
| |||
0 commit comments