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.
This commit is contained in:
Matthias Krüger 2024-03-18 06:58:49 +01:00 committed by GitHub
commit 86bb0bc41d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -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"