Remove Partial/Ord
from BoundRegion
This commit is contained in:
parent
e87d10846e
commit
459ea32a27
6 changed files with 20 additions and 20 deletions
|
@ -1074,7 +1074,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
let (sig, reg) = ty::print::FmtPrinter::new(self.tcx, Namespace::TypeNS)
|
let (sig, reg) = ty::print::FmtPrinter::new(self.tcx, Namespace::TypeNS)
|
||||||
.name_all_regions(sig)
|
.name_all_regions(sig)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let lts: Vec<String> = reg.into_values().map(|kind| kind.to_string()).collect();
|
let lts: Vec<String> =
|
||||||
|
reg.into_items().map(|(_, kind)| kind.to_string()).into_sorted_stable_ord();
|
||||||
(if lts.is_empty() { String::new() } else { format!("for<{}> ", lts.join(", ")) }, sig)
|
(if lts.is_empty() { String::new() } else { format!("for<{}> ", lts.join(", ")) }, sig)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@ use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeVisitableExt};
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
|
||||||
|
|
||||||
pub use rustc_type_ir::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
|
pub use rustc_type_ir::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -254,12 +252,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
self,
|
self,
|
||||||
value: Binder<'tcx, T>,
|
value: Binder<'tcx, T>,
|
||||||
mut fld_r: F,
|
mut fld_r: F,
|
||||||
) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
|
) -> (T, FxIndexMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||||
where
|
where
|
||||||
F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
|
F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
|
||||||
T: TypeFoldable<TyCtxt<'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 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);
|
let value = self.instantiate_bound_regions_uncached(value, real_fld_r);
|
||||||
(value, region_map)
|
(value, region_map)
|
||||||
|
|
|
@ -10,6 +10,7 @@ use crate::ty::{
|
||||||
use rustc_apfloat::ieee::{Double, Single};
|
use rustc_apfloat::ieee::{Double, Single};
|
||||||
use rustc_apfloat::Float;
|
use rustc_apfloat::Float;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||||
|
use rustc_data_structures::unord::UnordMap;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
|
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
|
||||||
use rustc_hir::def_id::{DefIdMap, DefIdSet, ModDefId, CRATE_DEF_ID, LOCAL_CRATE};
|
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 smallvec::SmallVec;
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use std::fmt::{self, Write as _};
|
use std::fmt::{self, Write as _};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
@ -2537,7 +2537,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||||
struct RegionFolder<'a, 'tcx> {
|
struct RegionFolder<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
current_index: ty::DebruijnIndex,
|
current_index: ty::DebruijnIndex,
|
||||||
region_map: BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
|
region_map: UnordMap<ty::BoundRegion, ty::Region<'tcx>>,
|
||||||
name: &'a mut (
|
name: &'a mut (
|
||||||
dyn FnMut(
|
dyn FnMut(
|
||||||
Option<ty::DebruijnIndex>, // Debruijn index of the folded late-bound region
|
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>(
|
pub fn name_all_regions<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
value: &ty::Binder<'tcx, T>,
|
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
|
where
|
||||||
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
|
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
|
@ -2691,7 +2691,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||||
write!(self, "{var:?}")?;
|
write!(self, "{var:?}")?;
|
||||||
}
|
}
|
||||||
start_or_continue(self, "", "> ");
|
start_or_continue(self, "", "> ");
|
||||||
(value.clone().skip_binder(), BTreeMap::default())
|
(value.clone().skip_binder(), UnordMap::default())
|
||||||
} else {
|
} else {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
|
@ -2763,7 +2763,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||||
tcx,
|
tcx,
|
||||||
current_index: ty::INNERMOST,
|
current_index: ty::INNERMOST,
|
||||||
name: &mut name,
|
name: &mut name,
|
||||||
region_map: BTreeMap::new(),
|
region_map: UnordMap::default(),
|
||||||
};
|
};
|
||||||
let new_value = value.clone().skip_binder().fold_with(&mut folder);
|
let new_value = value.clone().skip_binder().fold_with(&mut folder);
|
||||||
let region_map = folder.region_map;
|
let region_map = folder.region_map;
|
||||||
|
|
|
@ -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)]
|
#[derive(HashStable)]
|
||||||
/// The parameter representation of late-bound function parameters, "some region
|
/// The parameter representation of late-bound function parameters, "some region
|
||||||
/// at least as big as the scope `fr.scope`".
|
/// at least as big as the scope `fr.scope`".
|
||||||
|
@ -367,7 +367,7 @@ pub struct LateParamRegion {
|
||||||
pub bound_region: BoundRegionKind,
|
pub bound_region: BoundRegionKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)]
|
#[derive(Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Copy)]
|
||||||
#[derive(HashStable)]
|
#[derive(HashStable)]
|
||||||
pub enum BoundRegionKind {
|
pub enum BoundRegionKind {
|
||||||
/// An anonymous region parameter for a given fn (&T)
|
/// An anonymous region parameter for a given fn (&T)
|
||||||
|
@ -384,7 +384,7 @@ pub enum BoundRegionKind {
|
||||||
BrEnv,
|
BrEnv,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
||||||
#[derive(HashStable)]
|
#[derive(HashStable)]
|
||||||
pub struct BoundRegion {
|
pub struct BoundRegion {
|
||||||
pub var: BoundVar,
|
pub var: BoundVar,
|
||||||
|
|
|
@ -431,7 +431,7 @@ pub struct BoundVarReplacer<'me, 'tcx> {
|
||||||
// These three maps track the bound variable that were replaced by placeholders. It might be
|
// These three maps track the bound variable that were replaced by placeholders. It might be
|
||||||
// nice to remove these since we already have the `kind` in the placeholder; we really just need
|
// nice to remove these since we already have the `kind` in the placeholder; we really just need
|
||||||
// the `var` (but we *could* bring that into scope if we were to track them as we pass them).
|
// the `var` (but we *could* bring that into scope if we were to track them as we pass them).
|
||||||
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
||||||
mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
||||||
mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
||||||
// The current depth relative to *this* folding, *not* the entire normalization. In other words,
|
// The current depth relative to *this* folding, *not* the entire normalization. In other words,
|
||||||
|
@ -451,11 +451,12 @@ impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> {
|
||||||
value: T,
|
value: T,
|
||||||
) -> (
|
) -> (
|
||||||
T,
|
T,
|
||||||
BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
||||||
FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
||||||
BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
||||||
) {
|
) {
|
||||||
let mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion> = BTreeMap::new();
|
let mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion> =
|
||||||
|
FxIndexMap::default();
|
||||||
let mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy> = FxIndexMap::default();
|
let mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy> = FxIndexMap::default();
|
||||||
let mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar> = BTreeMap::new();
|
let mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar> = BTreeMap::new();
|
||||||
|
|
||||||
|
@ -574,7 +575,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
|
||||||
/// The inverse of [`BoundVarReplacer`]: replaces placeholders with the bound vars from which they came.
|
/// The inverse of [`BoundVarReplacer`]: replaces placeholders with the bound vars from which they came.
|
||||||
pub struct PlaceholderReplacer<'me, 'tcx> {
|
pub struct PlaceholderReplacer<'me, 'tcx> {
|
||||||
infcx: &'me InferCtxt<'tcx>,
|
infcx: &'me InferCtxt<'tcx>,
|
||||||
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
||||||
mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
||||||
mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
||||||
universe_indices: &'me [Option<ty::UniverseIndex>],
|
universe_indices: &'me [Option<ty::UniverseIndex>],
|
||||||
|
@ -584,7 +585,7 @@ pub struct PlaceholderReplacer<'me, 'tcx> {
|
||||||
impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> {
|
impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> {
|
||||||
pub fn replace_placeholders<T: TypeFoldable<TyCtxt<'tcx>>>(
|
pub fn replace_placeholders<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||||
infcx: &'me InferCtxt<'tcx>,
|
infcx: &'me InferCtxt<'tcx>,
|
||||||
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
||||||
mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
||||||
mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
||||||
universe_indices: &'me [Option<ty::UniverseIndex>],
|
universe_indices: &'me [Option<ty::UniverseIndex>],
|
||||||
|
|
|
@ -70,7 +70,7 @@ LL | f4(|_: (), _: ()| {});
|
||||||
| | found signature defined here
|
| | found signature defined here
|
||||||
| expected due to this
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected closure signature `for<'r, 'a> fn(&'a (), &'r ()) -> _`
|
= note: expected closure signature `for<'a, 'r> fn(&'a (), &'r ()) -> _`
|
||||||
found closure signature `fn((), ()) -> _`
|
found closure signature `fn((), ()) -> _`
|
||||||
note: required by a bound in `f4`
|
note: required by a bound in `f4`
|
||||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:19:25
|
--> $DIR/anonymous-higher-ranked-lifetime.rs:19:25
|
||||||
|
@ -217,7 +217,7 @@ LL | h2(|_: (), _: (), _: (), _: ()| {});
|
||||||
| | found signature defined here
|
| | found signature defined here
|
||||||
| expected due to this
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected closure signature `for<'t0, 'a> fn(&'a (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>, &'t0 (), for<'a, 'b> fn(&'a (), &'b ())) -> _`
|
= note: expected closure signature `for<'a, 't0> fn(&'a (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>, &'t0 (), for<'a, 'b> fn(&'a (), &'b ())) -> _`
|
||||||
found closure signature `fn((), (), (), ()) -> _`
|
found closure signature `fn((), (), (), ()) -> _`
|
||||||
note: required by a bound in `h2`
|
note: required by a bound in `h2`
|
||||||
--> $DIR/anonymous-higher-ranked-lifetime.rs:30:25
|
--> $DIR/anonymous-higher-ranked-lifetime.rs:30:25
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue