Commit 32efecb
committed
Add safety preconditions to alloc/src/boxed/thin.rs
Note that I've added `#[requires]` attributes to represent the safety conditions as code contracts. These are based on the "SAFETY:" comments in the original code. The conditions are:
1. For `with_header`, we require that the pointer is aligned.
2. For `drop`, we require that the value pointer is either null or aligned.
3. For `header`, we require that the pointer is aligned.
These contracts ensure that the safety conditions mentioned in the comments are checked at compile-time or runtime, depending on the contract system used.1 parent dc862c4 commit 32efecb
1 file changed
+31
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
| 192 | + | |
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
| |||
361 | 366 | | |
362 | 367 | | |
363 | 368 | | |
| 369 | + | |
364 | 370 | | |
365 | 371 | | |
366 | 372 | | |
| |||
404 | 410 | | |
405 | 411 | | |
406 | 412 | | |
| 413 | + | |
407 | 414 | | |
408 | 415 | | |
409 | 416 | | |
| |||
435 | 442 | | |
436 | 443 | | |
437 | 444 | | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
0 commit comments