Skip to content

Commit 8754bd3

Browse files
committed
Make folding generic over the interner
1 parent 8fcd967 commit 8754bd3

File tree

74 files changed

+442
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+442
-334
lines changed

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
106106
}
107107
}
108108

109-
impl<'tcx, T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx> ToUniverseInfo<'tcx>
109+
impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUniverseInfo<'tcx>
110110
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>
111111
{
112112
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
@@ -258,7 +258,7 @@ struct NormalizeQuery<'tcx, T> {
258258

259259
impl<'tcx, T> TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T>
260260
where
261-
T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx,
261+
T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx,
262262
{
263263
fn fallback_error(
264264
&self,

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12781278
/// we use this kind of hacky solution.
12791279
fn normalize_to_scc_representatives<T>(&self, tcx: TyCtxt<'tcx>, value: T) -> T
12801280
where
1281-
T: TypeFoldable<'tcx>,
1281+
T: TypeFoldable<TyCtxt<'tcx>>,
12821282
{
12831283
tcx.fold_regions(value, |r, _db| {
12841284
let vid = self.to_region_vid(r);

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
179179
/// region names in error messages.
180180
pub(crate) fn name_regions<T>(&self, tcx: TyCtxt<'tcx>, ty: T) -> T
181181
where
182-
T: TypeFoldable<'tcx>,
182+
T: TypeFoldable<TyCtxt<'tcx>>,
183183
{
184184
tcx.fold_regions(ty, |region, _| match *region {
185185
ty::ReVar(vid) => {

compiler/rustc_borrowck/src/renumber.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn renumber_mir<'tcx>(
3232
#[instrument(skip(infcx), level = "debug")]
3333
pub fn renumber_regions<'tcx, T>(infcx: &InferCtxt<'tcx>, value: T) -> T
3434
where
35-
T: TypeFoldable<'tcx>,
35+
T: TypeFoldable<TyCtxt<'tcx>>,
3636
{
3737
infcx.tcx.fold_regions(value, |_region, _depth| {
3838
let origin = NllRegionVariableOrigin::Existential { from_forall: false };
@@ -47,7 +47,7 @@ struct NllVisitor<'a, 'tcx> {
4747
impl<'a, 'tcx> NllVisitor<'a, 'tcx> {
4848
fn renumber_regions<T>(&mut self, value: T) -> T
4949
where
50-
T: TypeFoldable<'tcx>,
50+
T: TypeFoldable<TyCtxt<'tcx>>,
5151
{
5252
renumber_regions(self.infcx, value)
5353
}

compiler/rustc_borrowck/src/type_check/canonical.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt;
22

33
use rustc_infer::infer::{canonical::Canonical, InferOk};
44
use rustc_middle::mir::ConstraintCategory;
5-
use rustc_middle::ty::{self, ToPredicate, Ty, TypeFoldable};
5+
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable};
66
use rustc_span::def_id::DefId;
77
use rustc_span::Span;
88
use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
@@ -66,7 +66,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
6666
canonical: &Canonical<'tcx, T>,
6767
) -> T
6868
where
69-
T: TypeFoldable<'tcx>,
69+
T: TypeFoldable<TyCtxt<'tcx>>,
7070
{
7171
let old_universe = self.infcx.universe();
7272

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
179179
///
180180
/// FIXME: This should get removed once higher ranked region obligations
181181
/// are dealt with during trait solving.
182-
fn replace_placeholders_with_nll<T: TypeFoldable<'tcx>>(&mut self, value: T) -> T {
182+
fn replace_placeholders_with_nll<T: TypeFoldable<TyCtxt<'tcx>>>(&mut self, value: T) -> T {
183183
if value.has_placeholders() {
184184
self.tcx.fold_regions(value, |r, _| match *r {
185185
ty::RePlaceholder(placeholder) => {

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ trait InferCtxtExt<'tcx> {
695695
value: T,
696696
) -> T
697697
where
698-
T: TypeFoldable<'tcx>;
698+
T: TypeFoldable<TyCtxt<'tcx>>;
699699

700700
fn replace_bound_regions_with_nll_infer_vars<T>(
701701
&self,
@@ -705,7 +705,7 @@ trait InferCtxtExt<'tcx> {
705705
indices: &mut UniversalRegionIndices<'tcx>,
706706
) -> T
707707
where
708-
T: TypeFoldable<'tcx>;
708+
T: TypeFoldable<TyCtxt<'tcx>>;
709709

710710
fn replace_late_bound_regions_with_nll_infer_vars_in_recursive_scope(
711711
&self,
@@ -727,7 +727,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
727727
value: T,
728728
) -> T
729729
where
730-
T: TypeFoldable<'tcx>,
730+
T: TypeFoldable<TyCtxt<'tcx>>,
731731
{
732732
self.tcx.fold_regions(value, |_region, _depth| self.next_nll_region_var(origin))
733733
}
@@ -741,7 +741,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
741741
indices: &mut UniversalRegionIndices<'tcx>,
742742
) -> T
743743
where
744-
T: TypeFoldable<'tcx>,
744+
T: TypeFoldable<TyCtxt<'tcx>>,
745745
{
746746
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
747747
debug!(?br);
@@ -833,7 +833,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
833833
/// returned by `to_region_vid`.
834834
pub fn fold_to_region_vids<T>(&self, tcx: TyCtxt<'tcx>, value: T) -> T
835835
where
836-
T: TypeFoldable<'tcx>,
836+
T: TypeFoldable<TyCtxt<'tcx>>,
837837
{
838838
tcx.fold_regions(value, |region, _| tcx.mk_region(ty::ReVar(self.to_region_vid(region))))
839839
}

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl<'tcx> HasTargetSpec for FunctionCx<'_, '_, 'tcx> {
336336
impl<'tcx> FunctionCx<'_, '_, 'tcx> {
337337
pub(crate) fn monomorphize<T>(&self, value: T) -> T
338338
where
339-
T: TypeFoldable<'tcx> + Copy,
339+
T: TypeFoldable<TyCtxt<'tcx>> + Copy,
340340
{
341341
self.instance.subst_mir_and_normalize_erasing_regions(
342342
self.tcx,

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::traits::*;
33
use rustc_middle::mir;
44
use rustc_middle::mir::interpret::ErrorHandled;
55
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout};
6-
use rustc_middle::ty::{self, Instance, Ty, TypeFoldable, TypeVisitable};
6+
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitable};
77
use rustc_target::abi::call::{FnAbi, PassMode};
88

99
use std::iter;
@@ -105,7 +105,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
105105
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
106106
pub fn monomorphize<T>(&self, value: T) -> T
107107
where
108-
T: Copy + TypeFoldable<'tcx>,
108+
T: Copy + TypeFoldable<TyCtxt<'tcx>>,
109109
{
110110
debug!("monomorphize: self.instance={:?}", self.instance);
111111
self.instance.subst_mir_and_normalize_erasing_regions(

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
489489

490490
/// Call this on things you got out of the MIR (so it is as generic as the current
491491
/// stack frame), to bring it into the proper environment for this interpreter.
492-
pub(super) fn subst_from_current_frame_and_normalize_erasing_regions<T: TypeFoldable<'tcx>>(
492+
pub(super) fn subst_from_current_frame_and_normalize_erasing_regions<
493+
T: TypeFoldable<TyCtxt<'tcx>>,
494+
>(
493495
&self,
494496
value: T,
495497
) -> Result<T, InterpError<'tcx>> {
@@ -498,7 +500,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
498500

499501
/// Call this on things you got out of the MIR (so it is as generic as the provided
500502
/// stack frame), to bring it into the proper environment for this interpreter.
501-
pub(super) fn subst_from_frame_and_normalize_erasing_regions<T: TypeFoldable<'tcx>>(
503+
pub(super) fn subst_from_frame_and_normalize_erasing_regions<T: TypeFoldable<TyCtxt<'tcx>>>(
502504
&self,
503505
frame: &Frame<'mir, 'tcx, M::Provenance, M::FrameExtra>,
504506
value: T,

0 commit comments

Comments
 (0)