@@ -1392,20 +1392,25 @@ mod prim_usize {}
1392
1392
///
1393
1393
/// # Safety
1394
1394
///
1395
- /// For all types, `T: ?Sized`, and for all `t: &T` or `t: &mut T`, unsafe code may assume that
1396
- /// the following properties hold. Rust programmers must assume that, unless explicitly stated
1397
- /// otherwise, any Rust code they did not author themselves may rely on these properties, and that
1398
- /// violating them may cause that code to exhibit undefined behavior.
1395
+ /// For all types, `T: ?Sized`, and for all `t: &T` or `t: &mut T`, when such values cross an API
1396
+ /// boundary, the following invariants must generally be upheld:
1399
1397
///
1400
1398
/// * `t` is aligned to `align_of_val(t)`
1401
1399
/// * `t` is dereferenceable for `size_of_val(t)` many bytes
1402
1400
///
1403
1401
/// If `t` points at address `a`, being "dereferenceable" for N bytes means that the memory range
1404
1402
/// `[a, a + N)` is all contained within a single [allocated object].
1405
1403
///
1406
- /// Note that the precise validity invariants for reference types are a work in progress. In the
1407
- /// future, new guarantees may be added. However, the guarantees documented in this section will
1408
- /// never be removed.
1404
+ /// For instance, this means that unsafe code in a safe function may assume these invariants are
1405
+ /// ensured of arguments passed by the caller, and it may assume that these invariants are ensured
1406
+ /// of return values from any safe functions it calls. In most cases, the inverse is also true:
1407
+ /// unsafe code must not violate these invariants when passing arguments to safe functions or
1408
+ /// returning values from safe functions; such violations may result in undefined behavior. Where
1409
+ /// exceptions to this latter requirement exist, they will be called out explicitly in documentation.
1410
+ ///
1411
+ /// It is not decided yet whether unsafe code may violate these invariants temporarily on internal
1412
+ /// data. As a consequence, unsafe code which violates these invariants temporarily on internal data
1413
+ /// may become unsound in future versions of Rust depending on how this question is decided.
1409
1414
///
1410
1415
/// [allocated object]: ptr#allocated-object
1411
1416
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
0 commit comments