Skip to content

Commit c3a1ca6

Browse files
committed
Remove allow(rustc::potential_query_instability) in rustc_const_eval
The use of FxHashMap has been replaced with FxIndexMap. For more information see #84447
1 parent 21b2465 commit c3a1ca6

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

compiler/rustc_const_eval/src/const_eval/machine.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use rustc_hir::def::DefKind;
22
use rustc_middle::mir;
33
use rustc_middle::ty::{self, Ty, TyCtxt};
44
use std::borrow::Borrow;
5-
use std::collections::hash_map::Entry;
65
use std::hash::Hash;
76

8-
use rustc_data_structures::fx::FxHashMap;
7+
use rustc_data_structures::fx::FxIndexMap;
8+
use rustc_data_structures::fx::IndexEntry;
99
use std::fmt;
1010

1111
use rustc_ast::Mutability;
@@ -107,26 +107,26 @@ impl<'mir, 'tcx> CompileTimeInterpreter<'mir, 'tcx> {
107107
}
108108
}
109109

110-
impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> {
110+
impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxIndexMap<K, V> {
111111
#[inline(always)]
112112
fn contains_key<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> bool
113113
where
114114
K: Borrow<Q>,
115115
{
116-
FxHashMap::contains_key(self, k)
116+
FxIndexMap::contains_key(self, k)
117117
}
118118

119119
#[inline(always)]
120120
fn insert(&mut self, k: K, v: V) -> Option<V> {
121-
FxHashMap::insert(self, k, v)
121+
FxIndexMap::insert(self, k, v)
122122
}
123123

124124
#[inline(always)]
125125
fn remove<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> Option<V>
126126
where
127127
K: Borrow<Q>,
128128
{
129-
FxHashMap::remove(self, k)
129+
FxIndexMap::remove(self, k)
130130
}
131131

132132
#[inline(always)]
@@ -148,8 +148,8 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> {
148148
#[inline(always)]
149149
fn get_mut_or<E>(&mut self, k: K, vacant: impl FnOnce() -> Result<V, E>) -> Result<&mut V, E> {
150150
match self.entry(k) {
151-
Entry::Occupied(e) => Ok(e.into_mut()),
152-
Entry::Vacant(e) => {
151+
IndexEntry::Occupied(e) => Ok(e.into_mut()),
152+
IndexEntry::Vacant(e) => {
153153
let v = vacant()?;
154154
Ok(e.insert(v))
155155
}

compiler/rustc_const_eval/src/interpret/intern.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! that contains allocations whose mutability we cannot identify.)
1616
1717
use super::validity::RefTracking;
18-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
18+
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
1919
use rustc_errors::ErrorGuaranteed;
2020
use rustc_hir as hir;
2121
use rustc_middle::mir::interpret::InterpResult;
@@ -37,7 +37,7 @@ pub trait CompileTimeMachine<'mir, 'tcx, T> = Machine<
3737
ExtraFnVal = !,
3838
FrameExtra = (),
3939
AllocExtra = (),
40-
MemoryMap = FxHashMap<AllocId, (MemoryKind<T>, Allocation)>,
40+
MemoryMap = FxIndexMap<AllocId, (MemoryKind<T>, Allocation)>,
4141
>;
4242

4343
struct InternVisitor<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval::MemoryKind>> {
@@ -47,7 +47,7 @@ struct InternVisitor<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_ev
4747
ref_tracking: &'rt mut RefTracking<(MPlaceTy<'tcx>, InternMode)>,
4848
/// A list of all encountered allocations. After type-based interning, we traverse this list to
4949
/// also intern allocations that are only referenced by a raw pointer or inside a union.
50-
leftover_allocations: &'rt mut FxHashSet<AllocId>,
50+
leftover_allocations: &'rt mut FxIndexSet<AllocId>,
5151
/// The root kind of the value that we're looking at. This field is never mutated for a
5252
/// particular allocation. It is primarily used to make as many allocations as possible
5353
/// read-only so LLVM can place them in const memory.
@@ -79,7 +79,7 @@ struct IsStaticOrFn;
7979
/// to account for (e.g. for vtables).
8080
fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval::MemoryKind>>(
8181
ecx: &'rt mut InterpCx<'mir, 'tcx, M>,
82-
leftover_allocations: &'rt mut FxHashSet<AllocId>,
82+
leftover_allocations: &'rt mut FxIndexSet<AllocId>,
8383
alloc_id: AllocId,
8484
mode: InternMode,
8585
ty: Option<Ty<'tcx>>,
@@ -355,7 +355,7 @@ pub fn intern_const_alloc_recursive<
355355
// `leftover_allocations` collects *all* allocations we see, because some might not
356356
// be available in a typed way. They get interned at the end.
357357
let mut ref_tracking = RefTracking::empty();
358-
let leftover_allocations = &mut FxHashSet::default();
358+
let leftover_allocations = &mut FxIndexSet::default();
359359

360360
// start with the outermost allocation
361361
intern_shallow(

compiler/rustc_const_eval/src/interpret/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
426426
type ExtraFnVal = !;
427427

428428
type MemoryMap =
429-
rustc_data_structures::fx::FxHashMap<AllocId, (MemoryKind<Self::MemoryKind>, Allocation)>;
429+
rustc_data_structures::fx::FxIndexMap<AllocId, (MemoryKind<Self::MemoryKind>, Allocation)>;
430430
const GLOBAL_KIND: Option<Self::MemoryKind> = None; // no copying of globals from `tcx` to machine memory
431431

432432
type AllocExtra = ();

compiler/rustc_const_eval/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Rust MIR: a lowered representation of Rust.
2222
#![feature(yeet_expr)]
2323
#![feature(is_some_and)]
2424
#![recursion_limit = "256"]
25-
#![allow(rustc::potential_query_instability)]
2625

2726
#[macro_use]
2827
extern crate tracing;

0 commit comments

Comments
 (0)