Remove unnecessary RegionKind:: quals.

The variant names are exported, so we can use them directly (possibly
with a `ty::` qualifier). Lots of places already do this, this commit
just increases consistency.
This commit is contained in:
Nicholas Nethercote 2022-02-01 12:57:04 +11:00
parent 7024dc523a
commit 7eb15509ce
10 changed files with 56 additions and 71 deletions

View file

@ -711,7 +711,7 @@ fn bound_vars_for_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx
var: ty::BoundVar::from_usize(substs.len()),
kind: ty::BrAnon(substs.len() as u32),
};
tcx.mk_region(ty::RegionKind::ReLateBound(ty::INNERMOST, br)).into()
tcx.mk_region(ty::ReLateBound(ty::INNERMOST, br)).into()
}
ty::GenericParamDefKind::Const { .. } => tcx

View file

@ -35,7 +35,7 @@ use rustc_ast::ast;
use rustc_middle::traits::{ChalkEnvironmentAndGoal, ChalkRustInterner as RustInterner};
use rustc_middle::ty::fold::TypeFolder;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
use rustc_middle::ty::{self, Binder, Region, RegionKind, Ty, TyCtxt, TypeFoldable, TypeVisitor};
use rustc_middle::ty::{self, Binder, Region, Ty, TyCtxt, TypeFoldable, TypeVisitor};
use rustc_span::def_id::DefId;
use chalk_ir::{FnSig, ForeignDefId};
@ -449,32 +449,30 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
impl<'tcx> LowerInto<'tcx, chalk_ir::Lifetime<RustInterner<'tcx>>> for Region<'tcx> {
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::Lifetime<RustInterner<'tcx>> {
use rustc_middle::ty::RegionKind::*;
match *self {
ReEarlyBound(_) => {
ty::ReEarlyBound(_) => {
panic!("Should have already been substituted.");
}
ReLateBound(db, br) => chalk_ir::LifetimeData::BoundVar(chalk_ir::BoundVar::new(
ty::ReLateBound(db, br) => chalk_ir::LifetimeData::BoundVar(chalk_ir::BoundVar::new(
chalk_ir::DebruijnIndex::new(db.as_u32()),
br.var.as_usize(),
))
.intern(interner),
ReFree(_) => unimplemented!(),
ReStatic => chalk_ir::LifetimeData::Static.intern(interner),
ReVar(_) => unimplemented!(),
RePlaceholder(placeholder_region) => {
ty::ReFree(_) => unimplemented!(),
ty::ReStatic => chalk_ir::LifetimeData::Static.intern(interner),
ty::ReVar(_) => unimplemented!(),
ty::RePlaceholder(placeholder_region) => {
chalk_ir::LifetimeData::Placeholder(chalk_ir::PlaceholderIndex {
ui: chalk_ir::UniverseIndex { counter: placeholder_region.universe.index() },
idx: 0,
})
.intern(interner)
}
ReEmpty(ui) => {
ty::ReEmpty(ui) => {
chalk_ir::LifetimeData::Empty(chalk_ir::UniverseIndex { counter: ui.index() })
.intern(interner)
}
ReErased => chalk_ir::LifetimeData::Erased.intern(interner),
ty::ReErased => chalk_ir::LifetimeData::Erased.intern(interner),
}
}
}
@ -482,7 +480,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Lifetime<RustInterner<'tcx>>> for Region<'t
impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime<RustInterner<'tcx>> {
fn lower_into(self, interner: RustInterner<'tcx>) -> Region<'tcx> {
let kind = match self.data(interner) {
chalk_ir::LifetimeData::BoundVar(var) => ty::RegionKind::ReLateBound(
chalk_ir::LifetimeData::BoundVar(var) => ty::ReLateBound(
ty::DebruijnIndex::from_u32(var.debruijn.depth()),
ty::BoundRegion {
var: ty::BoundVar::from_usize(var.index),
@ -490,12 +488,10 @@ impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime<RustInterner<'t
},
),
chalk_ir::LifetimeData::InferenceVar(_var) => unimplemented!(),
chalk_ir::LifetimeData::Placeholder(p) => {
ty::RegionKind::RePlaceholder(ty::Placeholder {
universe: ty::UniverseIndex::from_usize(p.ui.counter),
name: ty::BoundRegionKind::BrAnon(p.idx as u32),
})
}
chalk_ir::LifetimeData::Placeholder(p) => ty::RePlaceholder(ty::Placeholder {
universe: ty::UniverseIndex::from_usize(p.ui.counter),
name: ty::BoundRegionKind::BrAnon(p.idx as u32),
}),
chalk_ir::LifetimeData::Static => return interner.tcx.lifetimes.re_static,
chalk_ir::LifetimeData::Empty(ui) => {
ty::ReEmpty(ty::UniverseIndex::from_usize(ui.counter))
@ -982,7 +978,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for NamedBoundVarSubstitutor<'a, 'tcx> {
ty::BrNamed(def_id, _name) => match self.named_parameters.get(&def_id) {
Some(idx) => {
let new_br = ty::BoundRegion { var: br.var, kind: ty::BrAnon(*idx) };
return self.tcx.mk_region(RegionKind::ReLateBound(index, new_br));
return self.tcx.mk_region(ty::ReLateBound(index, new_br));
}
None => panic!("Missing `BrNamed`."),
},
@ -1064,14 +1060,14 @@ impl<'tcx> TypeFolder<'tcx> for ParamsSubstitutor<'tcx> {
var: ty::BoundVar::from_u32(*idx),
kind: ty::BrAnon(*idx),
};
self.tcx.mk_region(RegionKind::ReLateBound(self.binder_index, br))
self.tcx.mk_region(ty::ReLateBound(self.binder_index, br))
}
None => {
let idx = self.named_regions.len() as u32;
let br =
ty::BoundRegion { var: ty::BoundVar::from_u32(idx), kind: ty::BrAnon(idx) };
self.named_regions.insert(_re.def_id, idx);
self.tcx.mk_region(RegionKind::ReLateBound(self.binder_index, br))
self.tcx.mk_region(ty::ReLateBound(self.binder_index, br))
}
},