mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Rename folder traits' tcx
method to interner
This commit is contained in:
parent
459e142413
commit
63ad5d0522
@ -465,7 +465,7 @@ struct RemapLateBound<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -830,13 +830,13 @@ impl<'a, 'tcx> ImplTraitInTraitCollector<'a, '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
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
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) {
|
||||
return *ty;
|
||||
@ -852,7 +852,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
|
||||
});
|
||||
self.types.insert(proj.def_id, (infer_ty, proj.substs));
|
||||
// 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 = self.ocx.normalize(
|
||||
&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.tcx(),
|
||||
self.interner(),
|
||||
ObligationCause::new(
|
||||
self.span,
|
||||
self.body_id,
|
||||
|
@ -851,7 +851,7 @@ fn infer_placeholder_type<'a>(
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for MakeNameable<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ struct EraseAllBoundRegions<'tcx> {
|
||||
// lead to unsoundness (we call `delay_span_bug` at the start
|
||||
// of `diagnostic_hir_wf_check`).
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseAllBoundRegions<'tcx> {
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> {
|
||||
|
@ -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);
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for TypeParamEraser<'_, 'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.0.tcx
|
||||
}
|
||||
|
||||
|
@ -764,7 +764,7 @@ struct EraseEarlyRegions<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEarlyRegions<'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.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> {
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'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);
|
||||
let e = self.report_error(t);
|
||||
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);
|
||||
let e = self.report_error(ct);
|
||||
self.replaced_with_error = Some(e);
|
||||
self.tcx().const_error_with_guaranteed(ct.ty(), e)
|
||||
self.interner().const_error_with_guaranteed(ct.ty(), e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ struct 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
|
||||
}
|
||||
|
||||
@ -738,7 +738,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
||||
let var = self.canonical_var(info, r.into());
|
||||
let br = ty::BoundRegion { var, kind: ty::BrAnon(var.as_u32(), None) };
|
||||
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
|
||||
@ -752,7 +752,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
||||
self.fold_ty(bound_to)
|
||||
} else {
|
||||
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)
|
||||
} else {
|
||||
let var = self.canonical_var(info, const_var.into());
|
||||
self.tcx().mk_const(
|
||||
self.interner().mk_const(
|
||||
ty::ConstKind::Bound(self.binder_index, var),
|
||||
self.fold_ty(const_var.ty()),
|
||||
)
|
||||
|
@ -847,7 +847,7 @@ struct ConstInferUnifier<'cx, 'tcx> {
|
||||
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ConstInferUnifier<'_, 'tcx> {
|
||||
type Error = TypeError<'tcx>;
|
||||
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
@ -875,7 +875,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ConstInferUnifier<'_, 'tcx> {
|
||||
.borrow_mut()
|
||||
.type_variables()
|
||||
.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()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl<'a, 'tcx> 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
|
||||
}
|
||||
|
||||
@ -124,13 +124,13 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
|
||||
| ty::ReError(_)
|
||||
| ty::ReErased => {
|
||||
// replace all free regions with 'erased
|
||||
self.tcx().lifetimes.re_erased
|
||||
self.interner().lifetimes.re_erased
|
||||
}
|
||||
ty::ReStatic => {
|
||||
if self.keep_static {
|
||||
r
|
||||
} else {
|
||||
self.tcx().lifetimes.re_erased
|
||||
self.interner().lifetimes.re_erased
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ pub struct 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
|
||||
}
|
||||
|
||||
|
@ -1853,7 +1853,7 @@ struct InferenceLiteralEraser<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceLiteralEraser<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -1871,7 +1871,7 @@ struct 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
|
||||
}
|
||||
|
||||
@ -2065,7 +2065,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceParamAndInferWithPlaceholder<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticVarResolver<'a, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
TypeFolder::tcx(&self.shallow_resolver)
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
TypeFolder::interner(&self.shallow_resolver)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -74,7 +74,7 @@ impl<'a, 'tcx> 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
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx
|
||||
.borrow_mut()
|
||||
.unwrap_region_constraints()
|
||||
.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,
|
||||
}
|
||||
@ -214,7 +214,7 @@ struct FullTypeResolver<'a, 'tcx> {
|
||||
impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
|
||||
type Error = FixupError<'tcx>;
|
||||
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ pub struct ExternalConstraintsData<'tcx> {
|
||||
|
||||
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
|
||||
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 {
|
||||
regions: (),
|
||||
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 {
|
||||
ir::TypeFolder::tcx(folder).intern_external_constraints(ExternalConstraintsData {
|
||||
ir::TypeFolder::interner(folder).intern_external_constraints(ExternalConstraintsData {
|
||||
regions: (),
|
||||
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
|
||||
})
|
||||
|
@ -53,7 +53,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Expander<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
|
@ -539,7 +539,7 @@ pub struct MakeSuggestableFolder<'tcx> {
|
||||
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
|
||||
type Error = ();
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ struct RegionEraserVisitor<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ where
|
||||
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
|
||||
H: FnMut(ty::Const<'tcx>) -> ty::Const<'tcx>,
|
||||
{
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ impl<'a, 'tcx> 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
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ impl<'tcx, D> ir::TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'tcx, D>
|
||||
where
|
||||
D: BoundVarReplacerDelegate<'tcx>,
|
||||
{
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ impl<'tcx> 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
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ fn polymorphize<'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
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for NormalizeAfterErasingRegionsFolder<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ impl<'tcx> TryNormalizeAfterErasingRegionsFolder<'tcx> {
|
||||
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for TryNormalizeAfterErasingRegionsFolder<'tcx> {
|
||||
type Error = NormalizationError<'tcx>;
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ impl<'tcx> ReverseMapper<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
||||
)
|
||||
.emit();
|
||||
|
||||
self.tcx().re_error(e)
|
||||
self.interner().re_error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,7 +188,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
||||
.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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2222,7 +2222,7 @@ struct 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
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for Ty<'tcx> {
|
||||
| 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,
|
||||
) -> Result<Self, F::Error> {
|
||||
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 kind = self.kind().try_fold_with(folder)?;
|
||||
if ty != self.ty() || kind != self.kind() {
|
||||
Ok(folder.tcx().mk_const(kind, ty))
|
||||
Ok(folder.interner().mk_const(kind, ty))
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
|
@ -1152,7 +1152,7 @@ struct SkipBindersAt<'tcx> {
|
||||
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for SkipBindersAt<'tcx> {
|
||||
type Error = ();
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -1173,7 +1173,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for SkipBindersAt<'tcx> {
|
||||
if index == self.index {
|
||||
Err(())
|
||||
} else {
|
||||
Ok(self.tcx().mk_bound(index.shifted_out(1), bv))
|
||||
Ok(self.interner().mk_bound(index.shifted_out(1), bv))
|
||||
}
|
||||
} else {
|
||||
ty.try_super_fold_with(self)
|
||||
@ -1187,7 +1187,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for SkipBindersAt<'tcx> {
|
||||
if index == self.index {
|
||||
Err(())
|
||||
} 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 {
|
||||
r.try_super_fold_with(self)
|
||||
@ -1201,7 +1201,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for SkipBindersAt<'tcx> {
|
||||
if index == self.index {
|
||||
Err(())
|
||||
} else {
|
||||
Ok(self.tcx().mk_const(
|
||||
Ok(self.interner().mk_const(
|
||||
ty::ConstKind::Bound(index.shifted_out(1), bv),
|
||||
ct.ty().try_fold_with(self)?,
|
||||
))
|
||||
|
@ -486,7 +486,11 @@ impl<'tcx> ir::TypeFoldable<TyCtxt<'tcx>> for SubstsRef<'tcx> {
|
||||
match self.len() {
|
||||
1 => {
|
||||
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 => {
|
||||
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] {
|
||||
Ok(self)
|
||||
} else {
|
||||
Ok(folder.tcx().intern_substs(&[param0, param1]))
|
||||
Ok(folder.interner().intern_substs(&[param0, param1]))
|
||||
}
|
||||
}
|
||||
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] {
|
||||
Ok(self)
|
||||
} 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)),
|
||||
@ -778,7 +782,7 @@ struct SubstFolder<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for SubstFolder<'a, 'tcx> {
|
||||
#[inline]
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -987,7 +991,7 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
|
||||
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);
|
||||
|
||||
result
|
||||
|
@ -843,7 +843,7 @@ impl<'tcx> OpaqueTypeExpander<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for OpaqueTypeExpander<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -1343,7 +1343,7 @@ where
|
||||
for t in iter {
|
||||
new_list.push(t.try_fold_with(folder)?)
|
||||
}
|
||||
Ok(intern(folder.tcx(), &new_list))
|
||||
Ok(intern(folder.interner(), &new_list))
|
||||
}
|
||||
Some((_, Err(err))) => {
|
||||
return Err(err);
|
||||
|
@ -860,7 +860,7 @@ pub struct 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
|
||||
}
|
||||
|
||||
|
@ -2675,7 +2675,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, '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
|
||||
}
|
||||
|
||||
|
@ -4091,7 +4091,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceImplTraitFolder<'tcx> {
|
||||
t.super_fold_with(self)
|
||||
}
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ impl<'a, 'b, 'tcx> 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()
|
||||
}
|
||||
|
||||
@ -503,7 +503,7 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
|
||||
Reveal::UserFacing => ty.super_fold_with(self),
|
||||
|
||||
Reveal::All => {
|
||||
let recursion_limit = self.tcx().recursion_limit();
|
||||
let recursion_limit = self.interner().recursion_limit();
|
||||
if !recursion_limit.value_within_limit(self.depth) {
|
||||
self.selcx.infcx.err_ctxt().report_overflow_error(
|
||||
&ty,
|
||||
@ -514,8 +514,8 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
|
||||
}
|
||||
|
||||
let substs = substs.fold_with(self);
|
||||
let generic_ty = self.tcx().bound_type_of(def_id);
|
||||
let concrete_ty = generic_ty.subst(self.tcx(), substs);
|
||||
let generic_ty = self.interner().bound_type_of(def_id);
|
||||
let concrete_ty = generic_ty.subst(self.interner(), substs);
|
||||
self.depth += 1;
|
||||
let folded_ty = self.fold_ty(concrete_ty);
|
||||
self.depth -= 1;
|
||||
@ -741,7 +741,7 @@ impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
@ -847,7 +847,7 @@ impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
@ -888,7 +888,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
|
||||
let db = ty::DebruijnIndex::from_usize(
|
||||
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,
|
||||
}
|
||||
@ -915,7 +915,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
|
||||
let db = ty::DebruijnIndex::from_usize(
|
||||
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,
|
||||
}
|
||||
@ -939,7 +939,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
|
||||
let db = ty::DebruijnIndex::from_usize(
|
||||
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,
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ struct QueryNormalizer<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx> {
|
||||
type Error = NoSolution;
|
||||
|
||||
fn tcx<'c>(&'c self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
|
||||
|
||||
Reveal::All => {
|
||||
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) {
|
||||
// A closure or generator may have itself as in its upvars.
|
||||
// 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);
|
||||
}
|
||||
|
||||
let generic_ty = self.tcx().bound_type_of(def_id);
|
||||
let concrete_ty = generic_ty.subst(self.tcx(), substs);
|
||||
let generic_ty = self.interner().bound_type_of(def_id);
|
||||
let concrete_ty = generic_ty.subst(self.interner(), substs);
|
||||
self.anon_depth += 1;
|
||||
if concrete_ty == ty {
|
||||
bug!(
|
||||
|
@ -770,7 +770,7 @@ struct 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
|
||||
}
|
||||
|
||||
|
@ -1008,7 +1008,7 @@ impl<'a, 'tcx> 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
|
||||
}
|
||||
|
||||
@ -1064,7 +1064,7 @@ impl<'tcx> ParamsSubstitutor<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamsSubstitutor<'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
@ -1140,7 +1140,7 @@ impl<'tcx> ReverseParamsSubstitutor<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseParamsSubstitutor<'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ pub trait TypeSuperFoldable<I: Interner>: TypeFoldable<I> {
|
||||
/// the infallible methods of this trait to ensure that the two APIs
|
||||
/// are coherent.
|
||||
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>
|
||||
where
|
||||
@ -150,7 +150,7 @@ pub trait TypeFolder<I: Interner>: FallibleTypeFolder<I, Error = !> {
|
||||
pub trait FallibleTypeFolder<I: Interner>: Sized {
|
||||
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>
|
||||
where
|
||||
@ -197,8 +197,8 @@ where
|
||||
{
|
||||
type Error = !;
|
||||
|
||||
fn tcx<'a>(&'a self) -> I {
|
||||
TypeFolder::tcx(self)
|
||||
fn interner(&self) -> I {
|
||||
TypeFolder::interner(self)
|
||||
}
|
||||
|
||||
fn try_fold_binder<T>(&mut self, t: I::Binder<T>) -> Result<I::Binder<T>, !>
|
||||
|
@ -735,7 +735,7 @@ struct 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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user