Commit 69c5564
authored
Rollup merge of rust-lang#125043 - RalfJung:ref-type-safety-invariant, r=scottmcm
reference type safety invariant docs: clarification
The old text could have been read as saying that you can call a function if these requirements are upheld, which is definitely not true as they are an underapproximation of the actual safety invariant.
I removed the part about functions relaxing the requirements via their documentation... this seems incoherent with saying that it may actually be unsound to ever temporarily violate the requirement. Furthermore, a function *cannot* just relax this for its return value, that would in general be unsound. And the part about "unsafe code in a safe function may assume these invariants are ensured of arguments passed by the caller" also interacts with relaxing things: clearly, if the invariant has been relaxed, unsafe code cannot rely on it any more. There may be a place to give general guidance on what kinds of function contracts can exist, but the reference type is definitely not the right place to write that down.
I also took a clarification from rust-lang#121965 that is orthogonal to the rest of that PR.
Cc ```@joshlf``` ```@scottmcm```1 file changed
+8
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1476 | 1476 | | |
1477 | 1477 | | |
1478 | 1478 | | |
1479 | | - | |
1480 | | - | |
1481 | | - | |
1482 | | - | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
1483 | 1485 | | |
1484 | 1486 | | |
1485 | 1487 | | |
1486 | | - | |
| 1488 | + | |
| 1489 | + | |
1487 | 1490 | | |
1488 | 1491 | | |
1489 | 1492 | | |
| |||
0 commit comments