From 4a055befbcbd460610944c53b61f1f5af56e358b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 30 Mar 2024 23:10:43 +0100 Subject: [PATCH] cotrol stacked borrows consistency check with its own feature flag --- Cargo.toml | 1 + ci/ci.sh | 17 ++++++++++++----- src/borrow_tracker/stacked_borrows/stack.rs | 10 +++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 041254e6f4..9d24d3c6f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ harness = false [features] default = ["stack-cache"] stack-cache = [] +stack-cache-consistency-check = ["stack-cache"] # Be aware that this file is inside a workspace when used via the # submodule in the rustc repo. That means there are many cargo features diff --git a/ci/ci.sh b/ci/ci.sh index 54c5d3087f..47a271d48c 100755 --- a/ci/ci.sh +++ b/ci/ci.sh @@ -22,17 +22,24 @@ if [ "$HOST_TARGET" = i686-pc-windows-msvc ]; then BASH="C:/Program Files/Git/usr/bin/bash" fi -# Determine configuration for installed build -echo "Installing release version of Miri" +# Global configuration export RUSTFLAGS="-D warnings" export CARGO_INCREMENTAL=0 export CARGO_EXTRA_FLAGS="--locked" + +# Determine configuration for installed build +echo "Installing release version of Miri" ./miri install -# Prepare debug build for direct `./miri` invocations -echo "Building debug version of Miri" +echo "Checking various feature flag configurations" ./miri check --no-default-features # make sure this can be built -./miri check --all-features # and this, too +./miri check # and this, too +# `--all-features` is used for the build below, so no extra check needed. + +# Prepare debug build for direct `./miri` invocations. +# We enable all features to make sure the Stacked Borrows consistency check runs. +echo "Building debug version of Miri" +export CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS --all-features" ./miri build --all-targets # the build that all the `./miri test` below will use endgroup diff --git a/src/borrow_tracker/stacked_borrows/stack.rs b/src/borrow_tracker/stacked_borrows/stack.rs index 712c26a9af..76430498e2 100644 --- a/src/borrow_tracker/stacked_borrows/stack.rs +++ b/src/borrow_tracker/stacked_borrows/stack.rs @@ -146,7 +146,7 @@ impl<'tcx> Stack { /// Panics if any of the caching mechanisms have broken, /// - The StackCache indices don't refer to the parallel items, /// - There are no Unique items outside of first_unique..last_unique - #[cfg(all(feature = "stack-cache", debug_assertions))] + #[cfg(feature = "stack-cache-consistency-check")] fn verify_cache_consistency(&self) { // Only a full cache needs to be valid. Also see the comments in find_granting_cache // and set_unknown_bottom. @@ -190,7 +190,7 @@ impl<'tcx> Stack { tag: ProvenanceExtra, exposed_tags: &FxHashSet, ) -> Result, ()> { - #[cfg(all(feature = "stack-cache", debug_assertions))] + #[cfg(feature = "stack-cache-consistency-check")] self.verify_cache_consistency(); let ProvenanceExtra::Concrete(tag) = tag else { @@ -327,7 +327,7 @@ impl<'tcx> Stack { // This primes the cache for the next access, which is almost always the just-added tag. self.cache.add(new_idx, new); - #[cfg(debug_assertions)] + #[cfg(feature = "stack-cache-consistency-check")] self.verify_cache_consistency(); } @@ -410,7 +410,7 @@ impl<'tcx> Stack { self.unique_range.end = self.unique_range.end.min(disable_start); } - #[cfg(all(feature = "stack-cache", debug_assertions))] + #[cfg(feature = "stack-cache-consistency-check")] self.verify_cache_consistency(); Ok(()) @@ -465,7 +465,7 @@ impl<'tcx> Stack { self.unique_range = 0..0; } - #[cfg(all(feature = "stack-cache", debug_assertions))] + #[cfg(feature = "stack-cache-consistency-check")] self.verify_cache_consistency(); Ok(()) }