add EarlyBinder::subst_identity; impl ParameterizedOverTcx (needed for rustc_metadata) and Value for EarlyBinder

This commit is contained in:
Kyle Matsuda 2023-01-10 11:53:35 -07:00
parent e9e0908367
commit c84917ad2e
3 changed files with 20 additions and 0 deletions

View File

@ -32,6 +32,10 @@ impl<T: ParameterizedOverTcx> ParameterizedOverTcx for ty::Binder<'static, T> {
type Value<'tcx> = ty::Binder<'tcx, T::Value<'tcx>>;
}
impl<T: ParameterizedOverTcx> ParameterizedOverTcx for ty::EarlyBinder<T> {
type Value<'tcx> = ty::EarlyBinder<T::Value<'tcx>>;
}
#[macro_export]
macro_rules! trivially_parameterized_over_tcx {
($($ty:ty),+ $(,)?) => {

View File

@ -713,6 +713,10 @@ pub fn subst(self, tcx: TyCtxt<'tcx>, substs: &[GenericArg<'tcx>]) -> T {
let mut folder = SubstFolder { tcx, substs, binders_passed: 0 };
self.0.fold_with(&mut folder)
}
pub fn subst_identity(self) -> T {
self.0
}
}
///////////////////////////////////////////////////////////////////////////

View File

@ -94,6 +94,18 @@ fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle: &[QueryInfo<DepKind>]) -> Self {
}
}
impl<'tcx> Value<TyCtxt<'tcx>, DepKind> for ty::EarlyBinder<Ty<'_>> {
fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle: &[QueryInfo<DepKind>]) -> Self {
ty::EarlyBinder(Ty::from_cycle_error(tcx, cycle))
}
}
impl<'tcx> Value<TyCtxt<'tcx>, DepKind> for ty::EarlyBinder<ty::Binder<'_, ty::FnSig<'_>>> {
fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle: &[QueryInfo<DepKind>]) -> Self {
ty::EarlyBinder(ty::Binder::from_cycle_error(tcx, cycle))
}
}
// item_and_field_ids should form a cycle where each field contains the
// type in the next element in the list
pub fn recursive_type_error(