Rollup merge of #133116 - RalfJung:const-null-ptr, r=dtolnay

stabilize const_ptr_is_null

FCP passed in https://github.com/rust-lang/rust/issues/74939.

The second commit cleans up const stability around UB checks a bit, now that everything they need (except for `const_eval_select`) is stable.

Fixes https://github.com/rust-lang/rust/issues/74939
This commit is contained in:
许杰友 Jieyou Xu (Joe)
2024-11-17 23:56:10 +08:00
committed by GitHub
11 changed files with 43 additions and 36 deletions

View File

@@ -263,6 +263,12 @@ impl<'tcx> CompileTimeInterpCx<'tcx> {
}
/// See documentation on the `ptr_guaranteed_cmp` intrinsic.
/// Returns `2` if the result is unknown.
/// Returns `1` if the pointers are guaranteed equal.
/// Returns `0` if the pointers are guaranteed inequal.
///
/// Note that this intrinsic is exposed on stable for comparison with null. In other words, any
/// change to this function that affects comparison with null is insta-stable!
fn guaranteed_cmp(&mut self, a: Scalar, b: Scalar) -> InterpResult<'tcx, u8> {
interp_ok(match (a, b) {
// Comparisons between integers are always known.