1
Fork 0

Rollup merge of #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 https://github.com/rust-lang/rust/pull/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`
This commit is contained in:
Matthias Krüger 2024-08-02 06:43:43 +02:00 committed by GitHub
commit 67fcb58347
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 9 additions and 35 deletions

View file

@ -690,9 +690,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
// zero-sized access
return Ok(&[]);
};
if alloc_ref.has_provenance() {
throw_ub_custom!(fluent::const_eval_raw_eq_with_provenance);
}
alloc_ref.get_bytes_strip_provenance()
};