Skip to content

Commit 723aced

Browse files
committed
Auto merge of #3434 - RalfJung:stacked-borrows-cache-consistency, r=RalfJung
cotrol stacked borrows consistency check with its own feature flag Fixes rust-lang/miri#3431
2 parents a8fd61b + 10217fd commit 723aced

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/tools/miri/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ harness = false
5959
[features]
6060
default = ["stack-cache"]
6161
stack-cache = []
62+
stack-cache-consistency-check = ["stack-cache"]
6263

6364
# Be aware that this file is inside a workspace when used via the
6465
# submodule in the rustc repo. That means there are many cargo features

src/tools/miri/ci/ci.sh

+12-5
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,24 @@ if [ "$HOST_TARGET" = i686-pc-windows-msvc ]; then
2222
BASH="C:/Program Files/Git/usr/bin/bash"
2323
fi
2424

25-
# Determine configuration for installed build
26-
echo "Installing release version of Miri"
25+
# Global configuration
2726
export RUSTFLAGS="-D warnings"
2827
export CARGO_INCREMENTAL=0
2928
export CARGO_EXTRA_FLAGS="--locked"
29+
30+
# Determine configuration for installed build
31+
echo "Installing release version of Miri"
3032
./miri install
3133

32-
# Prepare debug build for direct `./miri` invocations
33-
echo "Building debug version of Miri"
34+
echo "Checking various feature flag configurations"
3435
./miri check --no-default-features # make sure this can be built
35-
./miri check --all-features # and this, too
36+
./miri check # and this, too
37+
# `--all-features` is used for the build below, so no extra check needed.
38+
39+
# Prepare debug build for direct `./miri` invocations.
40+
# We enable all features to make sure the Stacked Borrows consistency check runs.
41+
echo "Building debug version of Miri"
42+
export CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS --all-features"
3643
./miri build --all-targets # the build that all the `./miri test` below will use
3744

3845
endgroup

src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'tcx> Stack {
146146
/// Panics if any of the caching mechanisms have broken,
147147
/// - The StackCache indices don't refer to the parallel items,
148148
/// - There are no Unique items outside of first_unique..last_unique
149-
#[cfg(all(feature = "stack-cache", debug_assertions))]
149+
#[cfg(feature = "stack-cache-consistency-check")]
150150
fn verify_cache_consistency(&self) {
151151
// Only a full cache needs to be valid. Also see the comments in find_granting_cache
152152
// and set_unknown_bottom.
@@ -190,7 +190,7 @@ impl<'tcx> Stack {
190190
tag: ProvenanceExtra,
191191
exposed_tags: &FxHashSet<BorTag>,
192192
) -> Result<Option<usize>, ()> {
193-
#[cfg(all(feature = "stack-cache", debug_assertions))]
193+
#[cfg(feature = "stack-cache-consistency-check")]
194194
self.verify_cache_consistency();
195195

196196
let ProvenanceExtra::Concrete(tag) = tag else {
@@ -327,7 +327,7 @@ impl<'tcx> Stack {
327327
// This primes the cache for the next access, which is almost always the just-added tag.
328328
self.cache.add(new_idx, new);
329329

330-
#[cfg(debug_assertions)]
330+
#[cfg(feature = "stack-cache-consistency-check")]
331331
self.verify_cache_consistency();
332332
}
333333

@@ -410,7 +410,7 @@ impl<'tcx> Stack {
410410
self.unique_range.end = self.unique_range.end.min(disable_start);
411411
}
412412

413-
#[cfg(all(feature = "stack-cache", debug_assertions))]
413+
#[cfg(feature = "stack-cache-consistency-check")]
414414
self.verify_cache_consistency();
415415

416416
Ok(())
@@ -465,7 +465,7 @@ impl<'tcx> Stack {
465465
self.unique_range = 0..0;
466466
}
467467

468-
#[cfg(all(feature = "stack-cache", debug_assertions))]
468+
#[cfg(feature = "stack-cache-consistency-check")]
469469
self.verify_cache_consistency();
470470
Ok(())
471471
}

0 commit comments

Comments
 (0)