Skip to content

Commit 28e4d22

Browse files
authored
Rollup merge of rust-lang#128453 - RalfJung:raw_eq, r=saethlin
raw_eq: using it on bytes with provenance is not UB (outside const-eval) The current behavior of raw_eq violates provenance monotonicity. See rust-lang#124921 for an explanation of provenance monotonicity. It is violated in raw_eq because comparing bytes without provenance is well-defined, but adding provenance makes the operation UB. So remove the no-provenance requirement from raw_eq. However, the requirement stays in-place for compile-time invocations of raw_eq, that indeed cannot deal with provenance. Cc `@rust-lang/opsem`
2 parents f859e54 + da48417 commit 28e4d22

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/intrinsics.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2436,11 +2436,13 @@ extern "rust-intrinsic" {
24362436
///
24372437
/// # Safety
24382438
///
2439-
/// It's UB to call this if any of the *bytes* in `*a` or `*b` are uninitialized or carry a
2440-
/// pointer value.
2439+
/// It's UB to call this if any of the *bytes* in `*a` or `*b` are uninitialized.
24412440
/// Note that this is a stricter criterion than just the *values* being
24422441
/// fully-initialized: if `T` has padding, it's UB to call this intrinsic.
24432442
///
2443+
/// At compile-time, it is furthermore UB to call this if any of the bytes
2444+
/// in `*a` or `*b` have provenance.
2445+
///
24442446
/// (The implementation is allowed to branch on the results of comparisons,
24452447
/// which is UB if any of their inputs are `undef`.)
24462448
#[rustc_const_unstable(feature = "const_intrinsic_raw_eq", issue = "none")]

0 commit comments

Comments
 (0)