mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Auto merge of #102674 - CastilloDel:master, r=oli-obk
Remove allow(rustc::potential_query_instability) in rustc_const_eval The use of FxHashMap has been replaced with FxIndexMap. Related to #84447
This commit is contained in:
commit
5237c4d83d
@ -2,10 +2,10 @@ use rustc_hir::def::DefKind;
|
|||||||
use rustc_middle::mir;
|
use rustc_middle::mir;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::collections::hash_map::Entry;
|
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
|
use rustc_data_structures::fx::IndexEntry;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use rustc_ast::Mutability;
|
use rustc_ast::Mutability;
|
||||||
@ -107,18 +107,18 @@ impl<'mir, 'tcx> CompileTimeInterpreter<'mir, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> {
|
impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxIndexMap<K, V> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn contains_key<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> bool
|
fn contains_key<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> bool
|
||||||
where
|
where
|
||||||
K: Borrow<Q>,
|
K: Borrow<Q>,
|
||||||
{
|
{
|
||||||
FxHashMap::contains_key(self, k)
|
FxIndexMap::contains_key(self, k)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn insert(&mut self, k: K, v: V) -> Option<V> {
|
fn insert(&mut self, k: K, v: V) -> Option<V> {
|
||||||
FxHashMap::insert(self, k, v)
|
FxIndexMap::insert(self, k, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
@ -126,7 +126,7 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> {
|
|||||||
where
|
where
|
||||||
K: Borrow<Q>,
|
K: Borrow<Q>,
|
||||||
{
|
{
|
||||||
FxHashMap::remove(self, k)
|
FxIndexMap::remove(self, k)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
@ -148,8 +148,8 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn get_mut_or<E>(&mut self, k: K, vacant: impl FnOnce() -> Result<V, E>) -> Result<&mut V, E> {
|
fn get_mut_or<E>(&mut self, k: K, vacant: impl FnOnce() -> Result<V, E>) -> Result<&mut V, E> {
|
||||||
match self.entry(k) {
|
match self.entry(k) {
|
||||||
Entry::Occupied(e) => Ok(e.into_mut()),
|
IndexEntry::Occupied(e) => Ok(e.into_mut()),
|
||||||
Entry::Vacant(e) => {
|
IndexEntry::Vacant(e) => {
|
||||||
let v = vacant()?;
|
let v = vacant()?;
|
||||||
Ok(e.insert(v))
|
Ok(e.insert(v))
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
//! that contains allocations whose mutability we cannot identify.)
|
//! that contains allocations whose mutability we cannot identify.)
|
||||||
|
|
||||||
use super::validity::RefTracking;
|
use super::validity::RefTracking;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::ErrorGuaranteed;
|
use rustc_errors::ErrorGuaranteed;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::mir::interpret::InterpResult;
|
use rustc_middle::mir::interpret::InterpResult;
|
||||||
@ -37,7 +37,7 @@ pub trait CompileTimeMachine<'mir, 'tcx, T> = Machine<
|
|||||||
ExtraFnVal = !,
|
ExtraFnVal = !,
|
||||||
FrameExtra = (),
|
FrameExtra = (),
|
||||||
AllocExtra = (),
|
AllocExtra = (),
|
||||||
MemoryMap = FxHashMap<AllocId, (MemoryKind<T>, Allocation)>,
|
MemoryMap = FxIndexMap<AllocId, (MemoryKind<T>, Allocation)>,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
struct InternVisitor<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval::MemoryKind>> {
|
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
|
|||||||
ref_tracking: &'rt mut RefTracking<(MPlaceTy<'tcx>, InternMode)>,
|
ref_tracking: &'rt mut RefTracking<(MPlaceTy<'tcx>, InternMode)>,
|
||||||
/// A list of all encountered allocations. After type-based interning, we traverse this list to
|
/// A list of all encountered allocations. After type-based interning, we traverse this list to
|
||||||
/// also intern allocations that are only referenced by a raw pointer or inside a union.
|
/// also intern allocations that are only referenced by a raw pointer or inside a union.
|
||||||
leftover_allocations: &'rt mut FxHashSet<AllocId>,
|
leftover_allocations: &'rt mut FxIndexSet<AllocId>,
|
||||||
/// The root kind of the value that we're looking at. This field is never mutated for a
|
/// The root kind of the value that we're looking at. This field is never mutated for a
|
||||||
/// particular allocation. It is primarily used to make as many allocations as possible
|
/// particular allocation. It is primarily used to make as many allocations as possible
|
||||||
/// read-only so LLVM can place them in const memory.
|
/// read-only so LLVM can place them in const memory.
|
||||||
@ -79,7 +79,7 @@ struct IsStaticOrFn;
|
|||||||
/// to account for (e.g. for vtables).
|
/// to account for (e.g. for vtables).
|
||||||
fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval::MemoryKind>>(
|
fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval::MemoryKind>>(
|
||||||
ecx: &'rt mut InterpCx<'mir, 'tcx, M>,
|
ecx: &'rt mut InterpCx<'mir, 'tcx, M>,
|
||||||
leftover_allocations: &'rt mut FxHashSet<AllocId>,
|
leftover_allocations: &'rt mut FxIndexSet<AllocId>,
|
||||||
alloc_id: AllocId,
|
alloc_id: AllocId,
|
||||||
mode: InternMode,
|
mode: InternMode,
|
||||||
ty: Option<Ty<'tcx>>,
|
ty: Option<Ty<'tcx>>,
|
||||||
@ -355,7 +355,7 @@ pub fn intern_const_alloc_recursive<
|
|||||||
// `leftover_allocations` collects *all* allocations we see, because some might not
|
// `leftover_allocations` collects *all* allocations we see, because some might not
|
||||||
// be available in a typed way. They get interned at the end.
|
// be available in a typed way. They get interned at the end.
|
||||||
let mut ref_tracking = RefTracking::empty();
|
let mut ref_tracking = RefTracking::empty();
|
||||||
let leftover_allocations = &mut FxHashSet::default();
|
let leftover_allocations = &mut FxIndexSet::default();
|
||||||
|
|
||||||
// start with the outermost allocation
|
// start with the outermost allocation
|
||||||
intern_shallow(
|
intern_shallow(
|
||||||
|
@ -426,7 +426,7 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
|
|||||||
type ExtraFnVal = !;
|
type ExtraFnVal = !;
|
||||||
|
|
||||||
type MemoryMap =
|
type MemoryMap =
|
||||||
rustc_data_structures::fx::FxHashMap<AllocId, (MemoryKind<Self::MemoryKind>, Allocation)>;
|
rustc_data_structures::fx::FxIndexMap<AllocId, (MemoryKind<Self::MemoryKind>, Allocation)>;
|
||||||
const GLOBAL_KIND: Option<Self::MemoryKind> = None; // no copying of globals from `tcx` to machine memory
|
const GLOBAL_KIND: Option<Self::MemoryKind> = None; // no copying of globals from `tcx` to machine memory
|
||||||
|
|
||||||
type AllocExtra = ();
|
type AllocExtra = ();
|
||||||
|
@ -22,7 +22,6 @@ Rust MIR: a lowered representation of Rust.
|
|||||||
#![feature(yeet_expr)]
|
#![feature(yeet_expr)]
|
||||||
#![feature(is_some_and)]
|
#![feature(is_some_and)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
#![allow(rustc::potential_query_instability)]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate tracing;
|
extern crate tracing;
|
||||||
|
Loading…
Reference in New Issue
Block a user