Skip to content

Commit

Permalink
Handle rustc_mir_dataflow cases of `rustc::potential_query_instabil…
Browse files Browse the repository at this point in the history
…ity` lint
  • Loading branch information
ismailarilik committed Nov 20, 2024
1 parent fda6892 commit 62c139e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions compiler/rustc_mir_dataflow/src/value_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::Range;

use rustc_abi::{FieldIdx, VariantIdx};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::{FxHashMap, FxIndexSet, StdEntry};
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet, IndexEntry};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_index::IndexVec;
use rustc_index::bit_set::BitSet;
Expand Down Expand Up @@ -36,12 +36,12 @@ rustc_index::newtype_index!(
pub struct StateData<V> {
bottom: V,
/// This map only contains values that are not `⊥`.
map: FxHashMap<ValueIndex, V>,
map: FxIndexMap<ValueIndex, V>,
}

impl<V: HasBottom> StateData<V> {
fn new() -> StateData<V> {
StateData { bottom: V::BOTTOM, map: FxHashMap::default() }
StateData { bottom: V::BOTTOM, map: FxIndexMap::default() }
}

fn get(&self, idx: ValueIndex) -> &V {
Expand All @@ -50,7 +50,7 @@ impl<V: HasBottom> StateData<V> {

fn insert(&mut self, idx: ValueIndex, elem: V) {
if elem.is_bottom() {
self.map.remove(&idx);
self.map.shift_remove(&idx);
} else {
self.map.insert(idx, elem);
}
Expand All @@ -70,14 +70,13 @@ impl<V: Clone> Clone for StateData<V> {
impl<V: JoinSemiLattice + Clone + HasBottom> JoinSemiLattice for StateData<V> {
fn join(&mut self, other: &Self) -> bool {
let mut changed = false;
#[allow(rustc::potential_query_instability)]
for (i, v) in other.map.iter() {
match self.map.entry(*i) {
StdEntry::Vacant(e) => {
IndexEntry::Vacant(e) => {
e.insert(v.clone());
changed = true
}
StdEntry::Occupied(e) => changed |= e.into_mut().join(v),
IndexEntry::Occupied(e) => changed |= e.into_mut().join(v),
}
}
changed
Expand Down

0 comments on commit 62c139e

Please sign in to comment.