1
Fork 0

address review again

This commit is contained in:
b-naber 2022-09-14 15:35:24 +02:00
parent ba00189d8e
commit 6af8fb7936
20 changed files with 119 additions and 520 deletions

View file

@ -2090,15 +2090,6 @@ impl<'tcx> Constant<'tcx> {
}
impl<'tcx> ConstantKind<'tcx> {
/// Returns `None` if the constant is not trivially safe for use in the type system.
#[inline]
pub fn const_for_ty(&self) -> Option<ty::Const<'tcx>> {
match self {
ConstantKind::Ty(c) => Some(*c),
ConstantKind::Val(..) | ConstantKind::Unevaluated(..) => None,
}
}
#[inline(always)]
pub fn ty(&self) -> Ty<'tcx> {
match self {
@ -2433,14 +2424,14 @@ impl<'tcx> ConstantKind<'tcx> {
debug!("error encountered during evaluation");
// Error was handled in `const_eval_resolve`. Here we just create a
// new unevaluated const and error hard later in codegen
Self::Ty(tcx.mk_const(ty::ConstS {
kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
Self::Unevaluated(
ty::Unevaluated {
def: def.to_global(),
substs: InternalSubsts::identity_for_item(tcx, def.did.to_def_id()),
promoted: (),
}),
promoted: None,
},
ty,
}))
)
}
}
}

View file

@ -826,9 +826,9 @@ mod size_asserts {
static_assert_size!(Expr<'_>, 64);
static_assert_size!(ExprKind<'_>, 40);
#[cfg(not(bootstrap))]
static_assert_size!(Pat<'_>, 64);
static_assert_size!(Pat<'_>, 72);
#[cfg(not(bootstrap))]
static_assert_size!(PatKind<'_>, 48);
static_assert_size!(PatKind<'_>, 56);
#[cfg(not(bootstrap))]
static_assert_size!(Stmt<'_>, 48);
#[cfg(not(bootstrap))]

View file

@ -302,6 +302,17 @@ impl<'tcx> TyCtxt<'tcx> {
{
value.fold_with(&mut RegionFolder::new(self, &mut f))
}
pub fn super_fold_regions<T>(
self,
value: T,
mut f: impl FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
) -> T
where
T: TypeSuperFoldable<'tcx>,
{
value.super_fold_with(&mut RegionFolder::new(self, &mut f))
}
}
/// Folds over the substructure of a type, visiting its component