Skip to content

Commit deda198

Browse files
committed
rustc_mir_transform: Enforce rustc::potential_query_instability lint
Stop allowing `rustc::potential_query_instability` on all of rustc_mir_transform and instead allow it on a case-by-case basis if it is safe to do so. In this particular crate, all instances were safe to allow.
1 parent 92ad4b4 commit deda198

File tree

6 files changed

+15
-1
lines changed

6 files changed

+15
-1
lines changed

compiler/rustc_mir_transform/src/const_prop.rs

+2
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
806806
// This loop can get very hot for some bodies: it check each local in each bb.
807807
// To avoid this quadratic behaviour, we only clear the locals that were modified inside
808808
// the current block.
809+
// The order in which we remove constness does not matter.
810+
#[allow(rustc::potential_query_instability)]
809811
for local in written_only_inside_own_block_locals.drain() {
810812
debug_assert_eq!(
811813
self.ecx.machine.can_const_prop[local],

compiler/rustc_mir_transform/src/const_prop_lint.rs

+2
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,8 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
670670
// This loop can get very hot for some bodies: it check each local in each bb.
671671
// To avoid this quadratic behaviour, we only clear the locals that were modified inside
672672
// the current block.
673+
// The order in which we remove constness does not matter.
674+
#[allow(rustc::potential_query_instability)]
673675
for local in written_only_inside_own_block_locals.drain() {
674676
debug_assert_eq!(
675677
self.ecx.machine.can_const_prop[local],

compiler/rustc_mir_transform/src/coverage/counters.rs

+2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ impl CoverageCounters {
181181
pub(super) fn bcb_edge_counters(
182182
&self,
183183
) -> impl Iterator<Item = (BasicCoverageBlock, BasicCoverageBlock, &BcbCounter)> {
184+
// The contract of bcb_edge_counters() makes no guarantees about ordering.
185+
#[allow(rustc::potential_query_instability)]
184186
self.bcb_edge_counters
185187
.iter()
186188
.map(|(&(from_bcb, to_bcb), counter_kind)| (from_bcb, to_bcb, counter_kind))

compiler/rustc_mir_transform/src/dest_prop.rs

+7
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
214214
// This is the set of merges we will apply this round. It is a subset of the candidates.
215215
let mut merges = FxHashMap::default();
216216

217+
// We put iterated entires into `merges` (another map) and
218+
// `merged_locals` (a set), so the insertion order does not matter.
219+
#[allow(rustc::potential_query_instability)]
217220
for (src, candidates) in candidates.c.iter() {
218221
if merged_locals.contains(*src) {
219222
continue;
@@ -736,11 +739,15 @@ fn find_candidates<'alloc, 'tcx>(
736739
let mut visitor = FindAssignments { body, candidates, borrowed };
737740
visitor.visit_body(body);
738741
// Deduplicate candidates
742+
// The order in which we dedup does not matter.
743+
#[allow(rustc::potential_query_instability)]
739744
for (_, cands) in candidates.iter_mut() {
740745
cands.sort();
741746
cands.dedup();
742747
}
743748
// Generate the reverse map
749+
// `candidates_reverse` is another map, so the order does not matter.
750+
#[allow(rustc::potential_query_instability)]
744751
for (src, cands) in candidates.iter() {
745752
for dest in cands.iter().copied() {
746753
candidates_reverse.entry(dest).or_default().push(*src);

compiler/rustc_mir_transform/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(rustc::potential_query_instability)]
21
#![deny(rustc::untranslatable_diagnostic)]
32
#![deny(rustc::diagnostic_outside_of_impl)]
43
#![feature(box_patterns)]

compiler/rustc_mir_transform/src/unreachable_prop.rs

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ impl MirPass<'_> for UnreachablePropagation {
5454
patch.apply(body);
5555

5656
// We do want do keep some unreachable blocks, but make them empty.
57+
// The order in which we clear bb statements does not matter.
58+
#[allow(rustc::potential_query_instability)]
5759
for bb in unreachable_blocks {
5860
body.basic_blocks_mut()[bb].statements.clear();
5961
}

0 commit comments

Comments
 (0)