Module ub_checks
Provides the assert_unsafe_precondition macro as well as some utility functions that cover
common preconditions.
Functions
- check_language_ub Determines whether we should check for language UB.
-
check_library_ub
Returns whether we should perform some UB-checking at runtime. This eventually evaluates to
cfg!(ub_checks), but behaves different fromcfg!when mixing crates built with different flags: if the crate has UB checks enabled or carries the#[rustc_preserve_ub_checks]attribute, evaluation is delayed until monomorphization (or until the call gets inlined into a crate that does not delay evaluation further); otherwise it can happen any time. - is_valid_allocation_size
-
maybe_is_aligned
Checks whether
ptris properly aligned with respect to the given alignment. -
maybe_is_aligned_and_not_null
Checks whether
ptris properly aligned with respect to the given alignment, and ifis_zst == false, thatptris not null. -
maybe_is_nonoverlapping
Checks whether the regions of memory starting at
srcanddstof sizecount * sizedo not overlap.
Macros
- assert_unsafe_precondition Checks that the preconditions of an unsafe function are followed.