Commit 122eb46
committed
Describe pointer fragment restriction in const final values
Let's add examples and explanatory notes to clarify the restriction
that the representation of the final value of a constant or static
initializer must only contain bytes with provenance in whole-pointer
groups.
We'll add a `compile_fail` example demonstrating how storing a pointer
that extends into padding creates pointer fragments in the final
value, causing compilation to fail and show to work around this by
explicitly zeroing the padding bytes.
Let's extend the existing note about uninitialized padding bytes to
provide deeper intuition about this restriction and explain how
constant evaluation makes the details of typed copies
observable (whether field-by-field or memory-block), how these details
are not yet fully specified in Rust, and why the compiler must be
allowed to reject initializers with uninitialized padding bytes to
preserve future flexibility (such as always setting padding to
uninitialized).
Context: rust-lang/rust#148470, rust-lang/rust#1489671 parent 4c2c96d commit 122eb46
1 file changed
+56
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
240 | 285 | | |
241 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
242 | 298 | | |
243 | 299 | | |
244 | 300 | | |
| |||
0 commit comments