about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-18 06:58:49 +0100
committerGitHub <noreply@github.com>2024-03-18 06:58:49 +0100
commit86bb0bc41da06e78321a946e5c706edc1e22df1a (patch)
tree3f7c36ce62f63267ceafce72fbe950cd79a90480
parentd9b47c1f2b4e5965500cc6f6d024dae486a65c0f (diff)
parent872781b22697882051481a4ed7c764551a8b2cf2 (diff)
Rollup merge of #122654 - RalfJung:interpret-comment, r=matthiaskrgr
interpret/memory: explain why we use == on bool

This came up in https://github.com/rust-lang/rust/pull/122636.
-rw-r--r--compiler/rustc_const_eval/src/interpret/memory.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs
index 86aad2e1642..a6ca4b2e0de 100644
--- a/compiler/rustc_const_eval/src/interpret/memory.rs
+++ b/compiler/rustc_const_eval/src/interpret/memory.rs
@@ -949,6 +949,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
     /// Runs the close in "validation" mode, which means the machine's memory read hooks will be
     /// suppressed. Needless to say, this must only be set with great care! Cannot be nested.
     pub(super) fn run_for_validation<R>(&self, f: impl FnOnce() -> R) -> R {
+        // This deliberately uses `==` on `bool` to follow the pattern
+        // `assert!(val.replace(new) == old)`.
         assert!(
             self.memory.validation_in_progress.replace(true) == false,
             "`validation_in_progress` was already set"