Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<'tcx> UniverseInfo<'tcx> {
pub(crate) fn report_erroneous_element(
&self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
placeholder: ty::PlaceholderRegion<'tcx>,
placeholder: ty::PlaceholderRegion<TyCtxt<'tcx>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should add type aliases for things from rustc_type_ir in rustc_middle with I replaced by TyCtxt<'tcx> so uses of it still just use ty::PlaceholderRegion<'tcx>`, see

pub type TyKind<'tcx> = ir::TyKind<TyCtxt<'tcx>>;
pub type TypeAndMut<'tcx> = ir::TypeAndMut<TyCtxt<'tcx>>;
pub type AliasTy<'tcx> = ir::AliasTy<TyCtxt<'tcx>>;
pub type FnSig<'tcx> = ir::FnSig<TyCtxt<'tcx>>;
pub type Binder<'tcx, T> = ir::Binder<TyCtxt<'tcx>, T>;
pub type EarlyBinder<'tcx, T> = ir::EarlyBinder<TyCtxt<'tcx>, T>;
pub type TypingMode<'tcx> = ir::TypingMode<TyCtxt<'tcx>>;
pub type Placeholder<'tcx, T> = ir::Placeholder<TyCtxt<'tcx>, T>;

error_element: RegionElement<'tcx>,
cause: ObligationCause<'tcx>,
) {
Expand Down Expand Up @@ -152,7 +152,7 @@ pub(crate) trait TypeOpInfo<'tcx> {
fn report_erroneous_element(
&self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
placeholder: ty::PlaceholderRegion<'tcx>,
placeholder: ty::PlaceholderRegion<TyCtxt<'tcx>>,
error_element: RegionElement<'tcx>,
cause: ObligationCause<'tcx>,
) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub(crate) enum RegionErrorKind<'tcx> {
/// The region element that erroneously must be outlived by `longer_fr`.
error_element: RegionElement<'tcx>,
/// The placeholder region.
placeholder: ty::PlaceholderRegion<'tcx>,
placeholder: ty::PlaceholderRegion<TyCtxt<'tcx>>,
},

/// Any other lifetime error.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
pub(crate) fn placeholders_contained_in(
&self,
r: RegionVid,
) -> impl Iterator<Item = ty::PlaceholderRegion<'tcx>> {
) -> impl Iterator<Item = ty::PlaceholderRegion<TyCtxt<'tcx>>> {
let scc = self.constraint_sccs.scc(r);
self.scc_values.placeholders_contained_in(scc)
}
Expand Down Expand Up @@ -1311,7 +1311,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
fn check_bound_universal_region(
&self,
longer_fr: RegionVid,
placeholder: ty::PlaceholderRegion<'tcx>,
placeholder: ty::PlaceholderRegion<TyCtxt<'tcx>>,
errors_buffer: &mut RegionErrors<'tcx>,
) {
debug!("check_bound_universal_region(fr={:?}, placeholder={:?})", longer_fr, placeholder,);
Expand Down
17 changes: 10 additions & 7 deletions compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) enum RegionElement<'tcx> {

/// A placeholder (e.g., instantiated from a `for<'a> fn(&'a u32)`
/// type).
PlaceholderRegion(ty::PlaceholderRegion<'tcx>),
PlaceholderRegion(ty::PlaceholderRegion<TyCtxt<'tcx>>),
}

/// Records the CFG locations where each region is live. When we initially compute liveness, we use
Expand Down Expand Up @@ -197,27 +197,30 @@ impl LivenessValues {
#[derive(Debug, Default)]
#[derive(Clone)] // FIXME(#146079)
pub(crate) struct PlaceholderIndices<'tcx> {
indices: FxIndexSet<ty::PlaceholderRegion<'tcx>>,
indices: FxIndexSet<ty::PlaceholderRegion<TyCtxt<'tcx>>>,
}

impl<'tcx> PlaceholderIndices<'tcx> {
/// Returns the `PlaceholderIndex` for the inserted `PlaceholderRegion`
pub(crate) fn insert(&mut self, placeholder: ty::PlaceholderRegion<'tcx>) -> PlaceholderIndex {
pub(crate) fn insert(
&mut self,
placeholder: ty::PlaceholderRegion<TyCtxt<'tcx>>,
) -> PlaceholderIndex {
let (index, _) = self.indices.insert_full(placeholder);
index.into()
}

pub(crate) fn lookup_index(
&self,
placeholder: ty::PlaceholderRegion<'tcx>,
placeholder: ty::PlaceholderRegion<TyCtxt<'tcx>>,
) -> PlaceholderIndex {
self.indices.get_index_of(&placeholder).unwrap().into()
}

pub(crate) fn lookup_placeholder(
&self,
placeholder: PlaceholderIndex,
) -> ty::PlaceholderRegion<'tcx> {
) -> ty::PlaceholderRegion<TyCtxt<'tcx>> {
self.indices[placeholder.index()]
}

Expand Down Expand Up @@ -362,7 +365,7 @@ impl<'tcx, N: Idx> RegionValues<'tcx, N> {
pub(crate) fn placeholders_contained_in(
&self,
r: N,
) -> impl Iterator<Item = ty::PlaceholderRegion<'tcx>> {
) -> impl Iterator<Item = ty::PlaceholderRegion<TyCtxt<'tcx>>> {
self.placeholders
.row(r)
.into_iter()
Expand Down Expand Up @@ -417,7 +420,7 @@ impl ToElementIndex<'_> for RegionVid {
}
}

impl<'tcx> ToElementIndex<'tcx> for ty::PlaceholderRegion<'tcx> {
impl<'tcx> ToElementIndex<'tcx> for ty::PlaceholderRegion<TyCtxt<'tcx>> {
fn add_to_row<N: Idx>(self, values: &mut RegionValues<'tcx, N>, row: N) -> bool
where
Self: Into<ty::Placeholder<TyCtxt<'tcx>, ty::BoundRegion>>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl<'tcx> MirTypeckRegionConstraints<'tcx> {
pub(crate) fn placeholder_region(
&mut self,
infcx: &InferCtxt<'tcx>,
placeholder: ty::PlaceholderRegion<'tcx>,
placeholder: ty::PlaceholderRegion<TyCtxt<'tcx>>,
) -> ty::Region<'tcx> {
let placeholder_index = self.placeholder_indices.insert(placeholder);
match self.placeholder_index_to_region.get(placeholder_index) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
#[instrument(skip(self), level = "debug")]
fn next_placeholder_region(
&mut self,
placeholder: ty::PlaceholderRegion<'tcx>,
placeholder: ty::PlaceholderRegion<TyCtxt<'tcx>>,
) -> ty::Region<'tcx> {
let reg =
self.type_checker.constraints.placeholder_region(self.type_checker.infcx, placeholder);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ pub enum NllRegionVariableOrigin<'tcx> {

/// "Universal" instantiation of a higher-ranked region (e.g.,
/// from a `for<'a> T` binder). Meant to represent "any region".
Placeholder(ty::PlaceholderRegion<'tcx>),
Placeholder(ty::PlaceholderRegion<TyCtxt<'tcx>>),

Existential {
name: Option<Symbol>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ where
&mut self,
origin: infer::SubregionOrigin<'tcx>,
region: ty::Region<'tcx>,
placeholder_ty: ty::PlaceholderType<'tcx>,
placeholder_ty: ty::PlaceholderType<TyCtxt<'tcx>>,
) {
let verify_bound = self
.verify_bound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct LeakCheck<'a, 'tcx> {
// is repurposed to store some placeholder `P` such that the weaker
// condition `S: P` must hold. (This is true if `S: S1` transitively and `S1
// = P`.)
scc_placeholders: IndexVec<LeakCheckScc, Option<ty::PlaceholderRegion<'tcx>>>,
scc_placeholders: IndexVec<LeakCheckScc, Option<ty::PlaceholderRegion<TyCtxt<'tcx>>>>,

// For each SCC S, track the minimum universe that flows into it. Note that
// this is both the minimum of the universes for every region that is a
Expand Down Expand Up @@ -258,15 +258,15 @@ impl<'a, 'tcx> LeakCheck<'a, 'tcx> {

fn placeholder_error(
&self,
placeholder1: ty::PlaceholderRegion<'tcx>,
placeholder2: ty::PlaceholderRegion<'tcx>,
placeholder1: ty::PlaceholderRegion<TyCtxt<'tcx>>,
placeholder2: ty::PlaceholderRegion<TyCtxt<'tcx>>,
) -> TypeError<'tcx> {
self.error(placeholder1, ty::Region::new_placeholder(self.tcx, placeholder2))
}

fn error(
&self,
placeholder: ty::PlaceholderRegion<'tcx>,
placeholder: ty::PlaceholderRegion<TyCtx<'tcx>>,
other_region: ty::Region<'tcx>,
) -> TypeError<'tcx> {
debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub struct Verify<'tcx> {
#[derive(Copy, Clone, PartialEq, Eq, Hash, TypeFoldable, TypeVisitable)]
pub enum GenericKind<'tcx> {
Param(ty::ParamTy),
Placeholder(ty::PlaceholderType<'tcx>),
Placeholder(ty::PlaceholderType<TyCtxt<'tcx>>),
Alias(ty::AliasTy<'tcx>),
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl<'tcx> Const<'tcx> {
#[inline]
pub fn new_placeholder(
tcx: TyCtxt<'tcx>,
placeholder: ty::PlaceholderConst<'tcx>,
placeholder: ty::PlaceholderConst<TyCtxt<'tcx>>,
) -> Const<'tcx> {
Const::new(tcx, ty::ConstKind::Placeholder(placeholder))
}
Expand Down Expand Up @@ -195,7 +195,7 @@ impl<'tcx> rustc_type_ir::inherent::Const<TyCtxt<'tcx>> for Const<'tcx> {
Const::new_canonical_bound(tcx, var)
}

fn new_placeholder(tcx: TyCtxt<'tcx>, placeholder: ty::PlaceholderConst<'tcx>) -> Self {
fn new_placeholder(tcx: TyCtxt<'tcx>, placeholder: ty::PlaceholderConst<TyCtxt<'tcx>>) -> Self {
Const::new_placeholder(tcx, placeholder)
}

Expand Down
13 changes: 8 additions & 5 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {

type FnInputTys = &'tcx [Ty<'tcx>];
type ParamTy = ParamTy;
type BoundTy = ty::BoundTy;
//type BoundTy = ty::BoundTy;
type Symbol = Symbol;

type PlaceholderTy = ty::PlaceholderType<'tcx>;
type PlaceholderTy = ty::PlaceholderType<TyCtxt<'tcx>>;
type ErrorGuaranteed = ErrorGuaranteed;
type BoundExistentialPredicates = &'tcx List<PolyExistentialPredicate<'tcx>>;

Expand All @@ -158,10 +158,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
type Safety = hir::Safety;
type Abi = ExternAbi;
type Const = ty::Const<'tcx>;
type PlaceholderConst = ty::PlaceholderConst<'tcx>;
//type PlaceholderConst = ty::PlaceholderConst<'tcx>;

type ParamConst = ty::ParamConst;
type BoundConst = ty::BoundConst;
//type BoundConst = ty::BoundConst;
type ValueConst = ty::Value<'tcx>;
type ExprConst = ty::Expr<'tcx>;
type ValTree = ty::ValTree<'tcx>;
Expand All @@ -170,7 +170,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
type EarlyParamRegion = ty::EarlyParamRegion;
type LateParamRegion = ty::LateParamRegion;
type BoundRegion = ty::BoundRegion;
type PlaceholderRegion = ty::PlaceholderRegion<'tcx>;
type BoundRegionKind = ty::BoundRegionKind;
type BoundVariableKind = ty::BoundVariableKind;
type BoundTyKind = ty::BoundTyKind;
//type PlaceholderRegion = ty::PlaceholderRegion<TyCtxt<'tcx>>;

type RegionAssumptions = &'tcx ty::List<ty::ArgOutlivesPredicate<'tcx>>;

Expand Down
Loading
Loading