Skip to content

Commit

Permalink
cotrol stacked borrows consistency check with its own feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 30, 2024
1 parent 7bec2db commit 4a055be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions ci/ci.sh
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/borrow_tracker/stacked_borrows/stack.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -190,7 +190,7 @@ impl<'tcx> Stack {
tag: ProvenanceExtra,
exposed_tags: &FxHashSet<BorTag>,
) -> Result<Option<usize>, ()> {
#[cfg(all(feature = "stack-cache", debug_assertions))]
#[cfg(feature = "stack-cache-consistency-check")]
self.verify_cache_consistency();

let ProvenanceExtra::Concrete(tag) = tag else {
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -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(())
}
Expand Down

0 comments on commit 4a055be

Please sign in to comment.