Remove Partial/Ord from BoundRegion

This commit is contained in:
Oli Scherer
2024-03-21 14:02:13 +00:00
parent e87d10846e
commit 459ea32a27
6 changed files with 20 additions and 20 deletions

View File

@@ -2,8 +2,6 @@ use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeVisitableExt};
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir::def_id::DefId;
use std::collections::BTreeMap;
pub use rustc_type_ir::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
///////////////////////////////////////////////////////////////////////////
@@ -254,12 +252,12 @@ impl<'tcx> TyCtxt<'tcx> {
self,
value: Binder<'tcx, T>,
mut fld_r: F,
) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
) -> (T, FxIndexMap<ty::BoundRegion, ty::Region<'tcx>>)
where
F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
T: TypeFoldable<TyCtxt<'tcx>>,
{
let mut region_map = BTreeMap::new();
let mut region_map = FxIndexMap::default();
let real_fld_r = |br: ty::BoundRegion| *region_map.entry(br).or_insert_with(|| fld_r(br));
let value = self.instantiate_bound_regions_uncached(value, real_fld_r);
(value, region_map)

View File

@@ -10,6 +10,7 @@ use crate::ty::{
use rustc_apfloat::ieee::{Double, Single};
use rustc_apfloat::Float;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_data_structures::unord::UnordMap;
use rustc_hir as hir;
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
use rustc_hir::def_id::{DefIdMap, DefIdSet, ModDefId, CRATE_DEF_ID, LOCAL_CRATE};
@@ -24,7 +25,6 @@ use rustc_target::spec::abi::Abi;
use smallvec::SmallVec;
use std::cell::Cell;
use std::collections::BTreeMap;
use std::fmt::{self, Write as _};
use std::iter;
use std::ops::{Deref, DerefMut};
@@ -2537,7 +2537,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
struct RegionFolder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
current_index: ty::DebruijnIndex,
region_map: BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
region_map: UnordMap<ty::BoundRegion, ty::Region<'tcx>>,
name: &'a mut (
dyn FnMut(
Option<ty::DebruijnIndex>, // Debruijn index of the folded late-bound region
@@ -2614,7 +2614,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
pub fn name_all_regions<T>(
&mut self,
value: &ty::Binder<'tcx, T>,
) -> Result<(T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>), fmt::Error>
) -> Result<(T, UnordMap<ty::BoundRegion, ty::Region<'tcx>>), fmt::Error>
where
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
{
@@ -2691,7 +2691,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
write!(self, "{var:?}")?;
}
start_or_continue(self, "", "> ");
(value.clone().skip_binder(), BTreeMap::default())
(value.clone().skip_binder(), UnordMap::default())
} else {
let tcx = self.tcx;
@@ -2763,7 +2763,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
tcx,
current_index: ty::INNERMOST,
name: &mut name,
region_map: BTreeMap::new(),
region_map: UnordMap::default(),
};
let new_value = value.clone().skip_binder().fold_with(&mut folder);
let region_map = folder.region_map;

View File

@@ -358,7 +358,7 @@ impl Atom for RegionVid {
}
}
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)]
#[derive(Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Copy)]
#[derive(HashStable)]
/// The parameter representation of late-bound function parameters, "some region
/// at least as big as the scope `fr.scope`".
@@ -367,7 +367,7 @@ pub struct LateParamRegion {
pub bound_region: BoundRegionKind,
}
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)]
#[derive(Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Copy)]
#[derive(HashStable)]
pub enum BoundRegionKind {
/// An anonymous region parameter for a given fn (&T)
@@ -384,7 +384,7 @@ pub enum BoundRegionKind {
BrEnv,
}
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable)]
pub struct BoundRegion {
pub var: BoundVar,