Skip to content

Commit 9fed354

Browse files
committed
docs: clarify hazard warns of UB risk that subsequent code must avoid
1 parent 01db759 commit 9fed354

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

pre-RFC.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ In contrast, **safety tags** represent safety properties using a formal language
5555
- `#[safety::requires(Prop1, Prop2, ...)]`**preconditions**: safety requirements that must be
5656
satisfied before invoking an unsafe API. Most unsafe APIs carry at least one precondition.
5757
By default, every property in `requires` is a precondition. A property explicitly tagged with
58-
`kind = "hazard"` instead denotes a temporary vulnerable state that deviates from Rust's safety
59-
principles (e.g. [`String::as_bytes_mut`]). Hazards are informational and do not loosen the
60-
mandatory preconditions.
58+
`kind = "hazard"` instead warns of a risk that subsequent program execution must avoid triggering,
59+
otherwise undefined behavior may occur (e.g. [`String::as_bytes_mut`] exposes a buffer that must
60+
not be used to produce invalid UTF-8). Hazards complement preconditions but are not themselves
61+
call-site obligations.
6162
- `#[safety::invariant(Prop)]`**struct invariants**: properties that must hold for every instance
6263
of a struct at all observable points.
6364
- `#[safety::verify]` — marks a function as a verification entry point.

0 commit comments

Comments
 (0)