1
Fork 0

Simplify CloneLiftImpls and TrivialTypeTraversalImpls.

They both allow for a lifetime other than `'tcx`, but this isn't needed.
This commit is contained in:
Nicholas Nethercote 2023-04-16 14:01:43 +10:00
parent 32f6e7a38e
commit d2b5a64579
6 changed files with 20 additions and 41 deletions

View file

@ -43,34 +43,26 @@ macro_rules! span_bug {
#[macro_export]
macro_rules! CloneLiftImpls {
(for <$tcx:lifetime> { $($ty:ty,)+ }) => {
($($ty:ty,)+) => {
$(
impl<$tcx> $crate::ty::Lift<$tcx> for $ty {
impl<'tcx> $crate::ty::Lift<'tcx> for $ty {
type Lifted = Self;
fn lift_to_tcx(self, _: $crate::ty::TyCtxt<$tcx>) -> Option<Self> {
fn lift_to_tcx(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
Some(self)
}
}
)+
};
($($ty:ty,)+) => {
CloneLiftImpls! {
for <'tcx> {
$($ty,)+
}
}
};
}
/// Used for types that are `Copy` and which **do not care arena
/// allocated data** (i.e., don't need to be folded).
#[macro_export]
macro_rules! TrivialTypeTraversalImpls {
(for <$tcx:lifetime> { $($ty:ty,)+ }) => {
($($ty:ty,)+) => {
$(
impl<$tcx> $crate::ty::fold::TypeFoldable<$crate::ty::TyCtxt<$tcx>> for $ty {
fn try_fold_with<F: $crate::ty::fold::FallibleTypeFolder<$crate::ty::TyCtxt<$tcx>>>(
impl<'tcx> $crate::ty::fold::TypeFoldable<$crate::ty::TyCtxt<'tcx>> for $ty {
fn try_fold_with<F: $crate::ty::fold::FallibleTypeFolder<$crate::ty::TyCtxt<'tcx>>>(
self,
_: &mut F,
) -> ::std::result::Result<Self, F::Error> {
@ -78,7 +70,7 @@ macro_rules! TrivialTypeTraversalImpls {
}
#[inline]
fn fold_with<F: $crate::ty::fold::TypeFolder<$crate::ty::TyCtxt<$tcx>>>(
fn fold_with<F: $crate::ty::fold::TypeFolder<$crate::ty::TyCtxt<'tcx>>>(
self,
_: &mut F,
) -> Self {
@ -86,9 +78,9 @@ macro_rules! TrivialTypeTraversalImpls {
}
}
impl<$tcx> $crate::ty::visit::TypeVisitable<$crate::ty::TyCtxt<$tcx>> for $ty {
impl<'tcx> $crate::ty::visit::TypeVisitable<$crate::ty::TyCtxt<'tcx>> for $ty {
#[inline]
fn visit_with<F: $crate::ty::visit::TypeVisitor<$crate::ty::TyCtxt<$tcx>>>(
fn visit_with<F: $crate::ty::visit::TypeVisitor<$crate::ty::TyCtxt<'tcx>>>(
&self,
_: &mut F)
-> ::std::ops::ControlFlow<F::BreakTy>
@ -98,14 +90,6 @@ macro_rules! TrivialTypeTraversalImpls {
}
)+
};
($($ty:ty,)+) => {
TrivialTypeTraversalImpls! {
for<'tcx> {
$($ty,)+
}
}
};
}
#[macro_export]