Skip to content

Commit 7c76eec

Browse files
committed
reference type safety invariant docs: clarification
1 parent 2259028 commit 7c76eec

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

library/core/src/primitive_docs.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1475,14 +1475,17 @@ mod prim_usize {}
14751475
///
14761476
/// For instance, this means that unsafe code in a safe function may assume these invariants are
14771477
/// ensured of arguments passed by the caller, and it may assume that these invariants are ensured
1478-
/// of return values from any safe functions it calls. In most cases, the inverse is also true:
1479-
/// unsafe code must not violate these invariants when passing arguments to safe functions or
1480-
/// returning values from safe functions; such violations may result in undefined behavior. Where
1481-
/// exceptions to this latter requirement exist, they will be called out explicitly in documentation.
1478+
/// of return values from any safe functions it calls.
1479+
///
1480+
/// For the other direction, things are more complicated: when unsafe code passes arguments
1481+
/// to safe functions or returns values from safe functions, they generally must *at least*
1482+
/// not violate these invariants. The full requirements are stronger, as the reference generally
1483+
/// must point to data that is safe to use at type `T`.
14821484
///
14831485
/// It is not decided yet whether unsafe code may violate these invariants temporarily on internal
14841486
/// data. As a consequence, unsafe code which violates these invariants temporarily on internal data
1485-
/// may become unsound in future versions of Rust depending on how this question is decided.
1487+
/// may be unsound or become unsound in future versions of Rust depending on how this question is
1488+
/// decided.
14861489
///
14871490
/// [allocated object]: ptr#allocated-object
14881491
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)