1
Fork 0

Rename folder traits' tcx method to interner

This commit is contained in:
Alan Egerton 2023-02-11 09:18:12 +00:00
parent 459e142413
commit 63ad5d0522
No known key found for this signature in database
GPG key ID: 7D4C2F6C22122532
33 changed files with 91 additions and 87 deletions

View file

@ -465,7 +465,7 @@ struct RemapLateBound<'a, 'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -830,13 +830,13 @@ impl<'a, 'tcx> ImplTraitInTraitCollector<'a, 'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.ocx.infcx.tcx self.ocx.infcx.tcx
} }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Alias(ty::Projection, proj) = ty.kind() if let ty::Alias(ty::Projection, proj) = ty.kind()
&& self.tcx().def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder && self.interner().def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder
{ {
if let Some((ty, _)) = self.types.get(&proj.def_id) { if let Some((ty, _)) = self.types.get(&proj.def_id) {
return *ty; return *ty;
@ -852,7 +852,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
}); });
self.types.insert(proj.def_id, (infer_ty, proj.substs)); self.types.insert(proj.def_id, (infer_ty, proj.substs));
// Recurse into bounds // Recurse into bounds
for (pred, pred_span) in self.tcx().bound_explicit_item_bounds(proj.def_id).subst_iter_copied(self.tcx(), proj.substs) { for (pred, pred_span) in self.interner().bound_explicit_item_bounds(proj.def_id).subst_iter_copied(self.interner(), proj.substs) {
let pred = pred.fold_with(self); let pred = pred.fold_with(self);
let pred = self.ocx.normalize( let pred = self.ocx.normalize(
&ObligationCause::misc(self.span, self.body_id), &ObligationCause::misc(self.span, self.body_id),
@ -861,7 +861,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
); );
self.ocx.register_obligation(traits::Obligation::new( self.ocx.register_obligation(traits::Obligation::new(
self.tcx(), self.interner(),
ObligationCause::new( ObligationCause::new(
self.span, self.span,
self.body_id, self.body_id,

View file

@ -851,7 +851,7 @@ fn infer_placeholder_type<'a>(
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for MakeNameable<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for MakeNameable<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -190,7 +190,7 @@ struct EraseAllBoundRegions<'tcx> {
// lead to unsoundness (we call `delay_span_bug` at the start // lead to unsoundness (we call `delay_span_bug` at the start
// of `diagnostic_hir_wf_check`). // of `diagnostic_hir_wf_check`).
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseAllBoundRegions<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseAllBoundRegions<'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> { fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> {

View file

@ -964,7 +964,7 @@ fn is_builtin_binop<'tcx>(lhs: Ty<'tcx>, rhs: Ty<'tcx>, op: hir::BinOp) -> bool
struct TypeParamEraser<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, Span); struct TypeParamEraser<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, Span);
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for TypeParamEraser<'_, 'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for TypeParamEraser<'_, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.0.tcx self.0.tcx
} }

View file

@ -764,7 +764,7 @@ struct EraseEarlyRegions<'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEarlyRegions<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEarlyRegions<'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
@ -780,7 +780,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEarlyRegions<'tcx> {
} }
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> { impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -797,7 +797,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t); debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t);
let e = self.report_error(t); let e = self.report_error(t);
self.replaced_with_error = Some(e); self.replaced_with_error = Some(e);
self.tcx().ty_error_with_guaranteed(e) self.interner().ty_error_with_guaranteed(e)
} }
} }
} }
@ -814,7 +814,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct); debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct);
let e = self.report_error(ct); let e = self.report_error(ct);
self.replaced_with_error = Some(e); self.replaced_with_error = Some(e);
self.tcx().const_error_with_guaranteed(ct.ty(), e) self.interner().const_error_with_guaranteed(ct.ty(), e)
} }
} }
} }

View file

@ -327,7 +327,7 @@ struct Canonicalizer<'cx, 'tcx> {
} }
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> { impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -738,7 +738,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
let var = self.canonical_var(info, r.into()); let var = self.canonical_var(info, r.into());
let br = ty::BoundRegion { var, kind: ty::BrAnon(var.as_u32(), None) }; let br = ty::BoundRegion { var, kind: ty::BrAnon(var.as_u32(), None) };
let region = ty::ReLateBound(self.binder_index, br); let region = ty::ReLateBound(self.binder_index, br);
self.tcx().mk_region(region) self.interner().mk_region(region)
} }
/// Given a type variable `ty_var` of the given kind, first check /// Given a type variable `ty_var` of the given kind, first check
@ -752,7 +752,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
self.fold_ty(bound_to) self.fold_ty(bound_to)
} else { } else {
let var = self.canonical_var(info, ty_var.into()); let var = self.canonical_var(info, ty_var.into());
self.tcx().mk_bound(self.binder_index, var.into()) self.interner().mk_bound(self.binder_index, var.into())
} }
} }
@ -771,7 +771,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
self.fold_const(bound_to) self.fold_const(bound_to)
} else { } else {
let var = self.canonical_var(info, const_var.into()); let var = self.canonical_var(info, const_var.into());
self.tcx().mk_const( self.interner().mk_const(
ty::ConstKind::Bound(self.binder_index, var), ty::ConstKind::Bound(self.binder_index, var),
self.fold_ty(const_var.ty()), self.fold_ty(const_var.ty()),
) )

View file

@ -847,7 +847,7 @@ struct ConstInferUnifier<'cx, 'tcx> {
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ConstInferUnifier<'_, 'tcx> { impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ConstInferUnifier<'_, 'tcx> {
type Error = TypeError<'tcx>; type Error = TypeError<'tcx>;
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -875,7 +875,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ConstInferUnifier<'_, 'tcx> {
.borrow_mut() .borrow_mut()
.type_variables() .type_variables()
.new_var(self.for_universe, origin); .new_var(self.for_universe, origin);
Ok(self.tcx().mk_ty_var(new_var_id)) Ok(self.interner().mk_ty_var(new_var_id))
} }
} }
} }
@ -953,7 +953,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ConstInferUnifier<'_, 'tcx> {
}, },
}, },
); );
Ok(self.tcx().mk_const(new_var_id, c.ty())) Ok(self.interner().mk_const(new_var_id, c.ty()))
} }
} }
} }

View file

@ -106,7 +106,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
} }
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -124,13 +124,13 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
| ty::ReError(_) | ty::ReError(_)
| ty::ReErased => { | ty::ReErased => {
// replace all free regions with 'erased // replace all free regions with 'erased
self.tcx().lifetimes.re_erased self.interner().lifetimes.re_erased
} }
ty::ReStatic => { ty::ReStatic => {
if self.keep_static { if self.keep_static {
r r
} else { } else {
self.tcx().lifetimes.re_erased self.interner().lifetimes.re_erased
} }
} }
} }

View file

@ -176,7 +176,7 @@ pub struct InferenceFudger<'a, 'tcx> {
} }
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -1853,7 +1853,7 @@ struct InferenceLiteralEraser<'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceLiteralEraser<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceLiteralEraser<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -1871,7 +1871,7 @@ struct ShallowResolver<'a, 'tcx> {
} }
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ShallowResolver<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ShallowResolver<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -2065,7 +2065,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceParamAndInferWithPlaceholder<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceParamAndInferWithPlaceholder<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -32,8 +32,8 @@ impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
} }
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticVarResolver<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticVarResolver<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
TypeFolder::tcx(&self.shallow_resolver) TypeFolder::interner(&self.shallow_resolver)
} }
#[inline] #[inline]
@ -74,7 +74,7 @@ impl<'a, 'tcx> OpportunisticRegionResolver<'a, 'tcx> {
} }
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -95,7 +95,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx
.borrow_mut() .borrow_mut()
.unwrap_region_constraints() .unwrap_region_constraints()
.opportunistic_resolve_var(rid); .opportunistic_resolve_var(rid);
TypeFolder::tcx(self).reuse_or_mk_region(r, ty::ReVar(resolved)) TypeFolder::interner(self).reuse_or_mk_region(r, ty::ReVar(resolved))
} }
_ => r, _ => r,
} }
@ -214,7 +214,7 @@ struct FullTypeResolver<'a, 'tcx> {
impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> { impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
type Error = FixupError<'tcx>; type Error = FixupError<'tcx>;
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -28,7 +28,7 @@ pub struct ExternalConstraintsData<'tcx> {
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> { impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> { fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
Ok(ir::FallibleTypeFolder::tcx(folder).intern_external_constraints( Ok(ir::FallibleTypeFolder::interner(folder).intern_external_constraints(
ExternalConstraintsData { ExternalConstraintsData {
regions: (), regions: (),
opaque_types: self opaque_types: self
@ -41,7 +41,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
} }
fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self { fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
ir::TypeFolder::tcx(folder).intern_external_constraints(ExternalConstraintsData { ir::TypeFolder::interner(folder).intern_external_constraints(ExternalConstraintsData {
regions: (), regions: (),
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(), opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
}) })

View file

@ -53,7 +53,7 @@ impl<'tcx> TyCtxt<'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Expander<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Expander<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {

View file

@ -539,7 +539,7 @@ pub struct MakeSuggestableFolder<'tcx> {
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> { impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
type Error = (); type Error = ();
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -35,7 +35,7 @@ struct RegionEraserVisitor<'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -36,7 +36,7 @@ where
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>, G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(ty::Const<'tcx>) -> ty::Const<'tcx>, H: FnMut(ty::Const<'tcx>) -> ty::Const<'tcx>,
{ {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -121,7 +121,7 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
} }
impl<'a, 'tcx> ir::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> { impl<'a, 'tcx> ir::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -198,7 +198,7 @@ impl<'tcx, D> ir::TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'tcx, D>
where where
D: BoundVarReplacerDelegate<'tcx>, D: BoundVarReplacerDelegate<'tcx>,
{ {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -461,7 +461,7 @@ impl<'tcx> Shifter<'tcx> {
} }
impl<'tcx> ir::TypeFolder<TyCtxt<'tcx>> for Shifter<'tcx> { impl<'tcx> ir::TypeFolder<TyCtxt<'tcx>> for Shifter<'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -675,7 +675,7 @@ fn polymorphize<'tcx>(
} }
impl<'tcx> ty::ir::TypeFolder<TyCtxt<'tcx>> for PolymorphizationFolder<'tcx> { impl<'tcx> ty::ir::TypeFolder<TyCtxt<'tcx>> for PolymorphizationFolder<'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -206,7 +206,7 @@ impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for NormalizeAfterErasingRegionsFolder<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for NormalizeAfterErasingRegionsFolder<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -244,7 +244,7 @@ impl<'tcx> TryNormalizeAfterErasingRegionsFolder<'tcx> {
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for TryNormalizeAfterErasingRegionsFolder<'tcx> { impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for TryNormalizeAfterErasingRegionsFolder<'tcx> {
type Error = NormalizationError<'tcx>; type Error = NormalizationError<'tcx>;
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -94,7 +94,7 @@ impl<'tcx> ReverseMapper<'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -143,7 +143,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
) )
.emit(); .emit();
self.tcx().re_error(e) self.interner().re_error(e)
} }
} }
} }
@ -188,7 +188,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
.emit(); .emit();
} }
self.tcx().ty_error() self.interner().ty_error()
} }
} }
} }
@ -216,7 +216,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
}); });
} }
self.tcx().const_error(ct.ty()) self.interner().const_error(ct.ty())
} }
} }
} }

View file

@ -2222,7 +2222,7 @@ struct RegionFolder<'a, 'tcx> {
} }
impl<'a, 'tcx> ty::ir::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> { impl<'a, 'tcx> ty::ir::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -486,7 +486,7 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for Ty<'tcx> {
| ty::Foreign(..) => return Ok(self), | ty::Foreign(..) => return Ok(self),
}; };
Ok(if *self.kind() == kind { self } else { folder.tcx().mk_ty(kind) }) Ok(if *self.kind() == kind { self } else { folder.interner().mk_ty(kind) })
} }
} }
@ -579,7 +579,7 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for ty::Predicate<'tcx> {
folder: &mut F, folder: &mut F,
) -> Result<Self, F::Error> { ) -> Result<Self, F::Error> {
let new = self.kind().try_fold_with(folder)?; let new = self.kind().try_fold_with(folder)?;
Ok(folder.tcx().reuse_or_mk_predicate(self, new)) Ok(folder.interner().reuse_or_mk_predicate(self, new))
} }
} }
@ -615,7 +615,7 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for ty::Const<'tcx> {
let ty = self.ty().try_fold_with(folder)?; let ty = self.ty().try_fold_with(folder)?;
let kind = self.kind().try_fold_with(folder)?; let kind = self.kind().try_fold_with(folder)?;
if ty != self.ty() || kind != self.kind() { if ty != self.ty() || kind != self.kind() {
Ok(folder.tcx().mk_const(kind, ty)) Ok(folder.interner().mk_const(kind, ty))
} else { } else {
Ok(self) Ok(self)
} }

View file

@ -1152,7 +1152,7 @@ struct SkipBindersAt<'tcx> {
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for SkipBindersAt<'tcx> { impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for SkipBindersAt<'tcx> {
type Error = (); type Error = ();
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -1173,7 +1173,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for SkipBindersAt<'tcx> {
if index == self.index { if index == self.index {
Err(()) Err(())
} else { } else {
Ok(self.tcx().mk_bound(index.shifted_out(1), bv)) Ok(self.interner().mk_bound(index.shifted_out(1), bv))
} }
} else { } else {
ty.try_super_fold_with(self) ty.try_super_fold_with(self)
@ -1187,7 +1187,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for SkipBindersAt<'tcx> {
if index == self.index { if index == self.index {
Err(()) Err(())
} else { } else {
Ok(self.tcx().mk_region(ty::ReLateBound(index.shifted_out(1), bv))) Ok(self.interner().mk_region(ty::ReLateBound(index.shifted_out(1), bv)))
} }
} else { } else {
r.try_super_fold_with(self) r.try_super_fold_with(self)
@ -1201,7 +1201,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for SkipBindersAt<'tcx> {
if index == self.index { if index == self.index {
Err(()) Err(())
} else { } else {
Ok(self.tcx().mk_const( Ok(self.interner().mk_const(
ty::ConstKind::Bound(index.shifted_out(1), bv), ty::ConstKind::Bound(index.shifted_out(1), bv),
ct.ty().try_fold_with(self)?, ct.ty().try_fold_with(self)?,
)) ))

View file

@ -486,7 +486,11 @@ impl<'tcx> ir::TypeFoldable<TyCtxt<'tcx>> for SubstsRef<'tcx> {
match self.len() { match self.len() {
1 => { 1 => {
let param0 = self[0].try_fold_with(folder)?; let param0 = self[0].try_fold_with(folder)?;
if param0 == self[0] { Ok(self) } else { Ok(folder.tcx().intern_substs(&[param0])) } if param0 == self[0] {
Ok(self)
} else {
Ok(folder.interner().intern_substs(&[param0]))
}
} }
2 => { 2 => {
let param0 = self[0].try_fold_with(folder)?; let param0 = self[0].try_fold_with(folder)?;
@ -494,7 +498,7 @@ impl<'tcx> ir::TypeFoldable<TyCtxt<'tcx>> for SubstsRef<'tcx> {
if param0 == self[0] && param1 == self[1] { if param0 == self[0] && param1 == self[1] {
Ok(self) Ok(self)
} else { } else {
Ok(folder.tcx().intern_substs(&[param0, param1])) Ok(folder.interner().intern_substs(&[param0, param1]))
} }
} }
0 => Ok(self), 0 => Ok(self),
@ -527,7 +531,7 @@ impl<'tcx> ir::TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<Ty<'tcx>> {
if param0 == self[0] && param1 == self[1] { if param0 == self[0] && param1 == self[1] {
Ok(self) Ok(self)
} else { } else {
Ok(folder.tcx().intern_type_list(&[param0, param1])) Ok(folder.interner().intern_type_list(&[param0, param1]))
} }
} }
_ => ty::util::fold_list(self, folder, |tcx, v| tcx.intern_type_list(v)), _ => ty::util::fold_list(self, folder, |tcx, v| tcx.intern_type_list(v)),
@ -778,7 +782,7 @@ struct SubstFolder<'a, 'tcx> {
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for SubstFolder<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for SubstFolder<'a, 'tcx> {
#[inline] #[inline]
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -987,7 +991,7 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
return val; return val;
} }
let result = ty::fold::shift_vars(TypeFolder::tcx(self), val, self.binders_passed); let result = ty::fold::shift_vars(TypeFolder::interner(self), val, self.binders_passed);
debug!("shift_vars: shifted result = {:?}", result); debug!("shift_vars: shifted result = {:?}", result);
result result

View file

@ -843,7 +843,7 @@ impl<'tcx> OpaqueTypeExpander<'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for OpaqueTypeExpander<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for OpaqueTypeExpander<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -1343,7 +1343,7 @@ where
for t in iter { for t in iter {
new_list.push(t.try_fold_with(folder)?) new_list.push(t.try_fold_with(folder)?)
} }
Ok(intern(folder.tcx(), &new_list)) Ok(intern(folder.interner(), &new_list))
} }
Some((_, Err(err))) => { Some((_, Err(err))) => {
return Err(err); return Err(err);

View file

@ -860,7 +860,7 @@ pub struct RegionReplacer<'a, 'tcx> {
} }
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionReplacer<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionReplacer<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -2675,7 +2675,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
} }
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ParamToVarFolder<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ParamToVarFolder<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -4091,7 +4091,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceImplTraitFolder<'tcx> {
t.super_fold_with(self) t.super_fold_with(self)
} }
fn tcx(&self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
} }

View file

@ -449,7 +449,7 @@ impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> {
} }
impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx> { impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx> {
fn tcx<'c>(&'c self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.selcx.tcx() self.selcx.tcx()
} }
@ -503,7 +503,7 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
Reveal::UserFacing => ty.super_fold_with(self), Reveal::UserFacing => ty.super_fold_with(self),
Reveal::All => { Reveal::All => {
let recursion_limit = self.tcx().recursion_limit(); let recursion_limit = self.interner().recursion_limit();
if !recursion_limit.value_within_limit(self.depth) { if !recursion_limit.value_within_limit(self.depth) {
self.selcx.infcx.err_ctxt().report_overflow_error( self.selcx.infcx.err_ctxt().report_overflow_error(
&ty, &ty,
@ -514,8 +514,8 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
} }
let substs = substs.fold_with(self); let substs = substs.fold_with(self);
let generic_ty = self.tcx().bound_type_of(def_id); let generic_ty = self.interner().bound_type_of(def_id);
let concrete_ty = generic_ty.subst(self.tcx(), substs); let concrete_ty = generic_ty.subst(self.interner(), substs);
self.depth += 1; self.depth += 1;
let folded_ty = self.fold_ty(concrete_ty); let folded_ty = self.fold_ty(concrete_ty);
self.depth -= 1; self.depth -= 1;
@ -741,7 +741,7 @@ impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -847,7 +847,7 @@ impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -888,7 +888,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
let db = ty::DebruijnIndex::from_usize( let db = ty::DebruijnIndex::from_usize(
self.universe_indices.len() - index + self.current_index.as_usize() - 1, self.universe_indices.len() - index + self.current_index.as_usize() - 1,
); );
self.tcx().mk_region(ty::ReLateBound(db, *replace_var)) self.interner().mk_region(ty::ReLateBound(db, *replace_var))
} }
None => r1, None => r1,
} }
@ -915,7 +915,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
let db = ty::DebruijnIndex::from_usize( let db = ty::DebruijnIndex::from_usize(
self.universe_indices.len() - index + self.current_index.as_usize() - 1, self.universe_indices.len() - index + self.current_index.as_usize() - 1,
); );
self.tcx().mk_bound(db, *replace_var) self.interner().mk_bound(db, *replace_var)
} }
None => ty, None => ty,
} }
@ -939,7 +939,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
let db = ty::DebruijnIndex::from_usize( let db = ty::DebruijnIndex::from_usize(
self.universe_indices.len() - index + self.current_index.as_usize() - 1, self.universe_indices.len() - index + self.current_index.as_usize() - 1,
); );
self.tcx().mk_const(ty::ConstKind::Bound(db, *replace_var), ct.ty()) self.interner().mk_const(ty::ConstKind::Bound(db, *replace_var), ct.ty())
} }
None => ct, None => ct,
} }

View file

@ -173,7 +173,7 @@ struct QueryNormalizer<'cx, 'tcx> {
impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx> { impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx> {
type Error = NoSolution; type Error = NoSolution;
fn tcx<'c>(&'c self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -214,7 +214,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
Reveal::All => { Reveal::All => {
let substs = substs.try_fold_with(self)?; let substs = substs.try_fold_with(self)?;
let recursion_limit = self.tcx().recursion_limit(); let recursion_limit = self.interner().recursion_limit();
if !recursion_limit.value_within_limit(self.anon_depth) { if !recursion_limit.value_within_limit(self.anon_depth) {
// A closure or generator may have itself as in its upvars. // A closure or generator may have itself as in its upvars.
// This should be checked handled by the recursion check for opaque // This should be checked handled by the recursion check for opaque
@ -228,8 +228,8 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
return ty.try_super_fold_with(self); return ty.try_super_fold_with(self);
} }
let generic_ty = self.tcx().bound_type_of(def_id); let generic_ty = self.interner().bound_type_of(def_id);
let concrete_ty = generic_ty.subst(self.tcx(), substs); let concrete_ty = generic_ty.subst(self.interner(), substs);
self.anon_depth += 1; self.anon_depth += 1;
if concrete_ty == ty { if concrete_ty == ty {
bug!( bug!(

View file

@ -770,7 +770,7 @@ struct ReplaceOpaqueTyFolder<'tcx> {
} }
impl<'tcx> ty::ir::TypeFolder<TyCtxt<'tcx>> for ReplaceOpaqueTyFolder<'tcx> { impl<'tcx> ty::ir::TypeFolder<TyCtxt<'tcx>> for ReplaceOpaqueTyFolder<'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -1008,7 +1008,7 @@ impl<'a, 'tcx> NamedBoundVarSubstitutor<'a, 'tcx> {
} }
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for NamedBoundVarSubstitutor<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for NamedBoundVarSubstitutor<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -1064,7 +1064,7 @@ impl<'tcx> ParamsSubstitutor<'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamsSubstitutor<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamsSubstitutor<'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -1140,7 +1140,7 @@ impl<'tcx> ReverseParamsSubstitutor<'tcx> {
} }
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseParamsSubstitutor<'tcx> { impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseParamsSubstitutor<'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -101,7 +101,7 @@ pub trait TypeSuperFoldable<I: Interner>: TypeFoldable<I> {
/// the infallible methods of this trait to ensure that the two APIs /// the infallible methods of this trait to ensure that the two APIs
/// are coherent. /// are coherent.
pub trait TypeFolder<I: Interner>: FallibleTypeFolder<I, Error = !> { pub trait TypeFolder<I: Interner>: FallibleTypeFolder<I, Error = !> {
fn tcx(&self) -> I; fn interner(&self) -> I;
fn fold_binder<T>(&mut self, t: I::Binder<T>) -> I::Binder<T> fn fold_binder<T>(&mut self, t: I::Binder<T>) -> I::Binder<T>
where where
@ -150,7 +150,7 @@ pub trait TypeFolder<I: Interner>: FallibleTypeFolder<I, Error = !> {
pub trait FallibleTypeFolder<I: Interner>: Sized { pub trait FallibleTypeFolder<I: Interner>: Sized {
type Error; type Error;
fn tcx<'a>(&'a self) -> I; fn interner(&self) -> I;
fn try_fold_binder<T>(&mut self, t: I::Binder<T>) -> Result<I::Binder<T>, Self::Error> fn try_fold_binder<T>(&mut self, t: I::Binder<T>) -> Result<I::Binder<T>, Self::Error>
where where
@ -197,8 +197,8 @@ where
{ {
type Error = !; type Error = !;
fn tcx<'a>(&'a self) -> I { fn interner(&self) -> I {
TypeFolder::tcx(self) TypeFolder::interner(self)
} }
fn try_fold_binder<T>(&mut self, t: I::Binder<T>) -> Result<I::Binder<T>, !> fn try_fold_binder<T>(&mut self, t: I::Binder<T>) -> Result<I::Binder<T>, !>

View file

@ -735,7 +735,7 @@ struct RegionReplacer<'a, 'tcx> {
} }
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionReplacer<'a, 'tcx> { impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionReplacer<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { fn interner(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }