Skip to content

Commit d2b5a64

Browse files
committed
Simplify CloneLiftImpls and TrivialTypeTraversalImpls.
They both allow for a lifetime other than `'tcx`, but this isn't needed.
1 parent 32f6e7a commit d2b5a64

File tree

6 files changed

+20
-41
lines changed

6 files changed

+20
-41
lines changed

compiler/rustc_middle/src/infer/canonical.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,8 @@ pub type QueryOutlivesConstraint<'tcx> =
400400
(ty::OutlivesPredicate<GenericArg<'tcx>, Region<'tcx>>, ConstraintCategory<'tcx>);
401401

402402
TrivialTypeTraversalAndLiftImpls! {
403-
for <'tcx> {
404-
crate::infer::canonical::Certainty,
405-
crate::infer::canonical::CanonicalTyVarKind,
406-
}
403+
crate::infer::canonical::Certainty,
404+
crate::infer::canonical::CanonicalTyVarKind,
407405
}
408406

409407
impl<'tcx> CanonicalVarValues<'tcx> {

compiler/rustc_middle/src/macros.rs

+9-25
Original file line numberDiff line numberDiff line change
@@ -43,52 +43,44 @@ macro_rules! span_bug {
4343

4444
#[macro_export]
4545
macro_rules! CloneLiftImpls {
46-
(for <$tcx:lifetime> { $($ty:ty,)+ }) => {
46+
($($ty:ty,)+) => {
4747
$(
48-
impl<$tcx> $crate::ty::Lift<$tcx> for $ty {
48+
impl<'tcx> $crate::ty::Lift<'tcx> for $ty {
4949
type Lifted = Self;
50-
fn lift_to_tcx(self, _: $crate::ty::TyCtxt<$tcx>) -> Option<Self> {
50+
fn lift_to_tcx(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
5151
Some(self)
5252
}
5353
}
5454
)+
5555
};
56-
57-
($($ty:ty,)+) => {
58-
CloneLiftImpls! {
59-
for <'tcx> {
60-
$($ty,)+
61-
}
62-
}
63-
};
6456
}
6557

6658
/// Used for types that are `Copy` and which **do not care arena
6759
/// allocated data** (i.e., don't need to be folded).
6860
#[macro_export]
6961
macro_rules! TrivialTypeTraversalImpls {
70-
(for <$tcx:lifetime> { $($ty:ty,)+ }) => {
62+
($($ty:ty,)+) => {
7163
$(
72-
impl<$tcx> $crate::ty::fold::TypeFoldable<$crate::ty::TyCtxt<$tcx>> for $ty {
73-
fn try_fold_with<F: $crate::ty::fold::FallibleTypeFolder<$crate::ty::TyCtxt<$tcx>>>(
64+
impl<'tcx> $crate::ty::fold::TypeFoldable<$crate::ty::TyCtxt<'tcx>> for $ty {
65+
fn try_fold_with<F: $crate::ty::fold::FallibleTypeFolder<$crate::ty::TyCtxt<'tcx>>>(
7466
self,
7567
_: &mut F,
7668
) -> ::std::result::Result<Self, F::Error> {
7769
Ok(self)
7870
}
7971

8072
#[inline]
81-
fn fold_with<F: $crate::ty::fold::TypeFolder<$crate::ty::TyCtxt<$tcx>>>(
73+
fn fold_with<F: $crate::ty::fold::TypeFolder<$crate::ty::TyCtxt<'tcx>>>(
8274
self,
8375
_: &mut F,
8476
) -> Self {
8577
self
8678
}
8779
}
8880

89-
impl<$tcx> $crate::ty::visit::TypeVisitable<$crate::ty::TyCtxt<$tcx>> for $ty {
81+
impl<'tcx> $crate::ty::visit::TypeVisitable<$crate::ty::TyCtxt<'tcx>> for $ty {
9082
#[inline]
91-
fn visit_with<F: $crate::ty::visit::TypeVisitor<$crate::ty::TyCtxt<$tcx>>>(
83+
fn visit_with<F: $crate::ty::visit::TypeVisitor<$crate::ty::TyCtxt<'tcx>>>(
9284
&self,
9385
_: &mut F)
9486
-> ::std::ops::ControlFlow<F::BreakTy>
@@ -98,14 +90,6 @@ macro_rules! TrivialTypeTraversalImpls {
9890
}
9991
)+
10092
};
101-
102-
($($ty:ty,)+) => {
103-
TrivialTypeTraversalImpls! {
104-
for<'tcx> {
105-
$($ty,)+
106-
}
107-
}
108-
};
10993
}
11094

11195
#[macro_export]

compiler/rustc_middle/src/mir/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,7 @@ pub enum BindingForm<'tcx> {
714714
}
715715

716716
TrivialTypeTraversalAndLiftImpls! {
717-
for<'tcx> {
718-
BindingForm<'tcx>,
719-
}
717+
BindingForm<'tcx>,
720718
}
721719

722720
mod binding_form_impl {

compiler/rustc_middle/src/mir/type_foldable.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ TrivialTypeTraversalAndLiftImpls! {
2525
}
2626

2727
TrivialTypeTraversalImpls! {
28-
for <'tcx> {
29-
ConstValue<'tcx>,
30-
}
28+
ConstValue<'tcx>,
3129
}
3230

3331
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx [InlineAsmTemplatePiece] {

compiler/rustc_middle/src/ty/context.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1329,9 +1329,12 @@ nop_list_lift! {bound_variable_kinds; ty::BoundVariableKind => ty::BoundVariable
13291329
// This is the impl for `&'a InternalSubsts<'a>`.
13301330
nop_list_lift! {substs; GenericArg<'a> => GenericArg<'tcx>}
13311331

1332-
CloneLiftImpls! { for<'tcx> {
1333-
Constness, traits::WellFormedLoc, ImplPolarity, crate::mir::ReturnConstraint,
1334-
} }
1332+
CloneLiftImpls! {
1333+
Constness,
1334+
traits::WellFormedLoc,
1335+
ImplPolarity,
1336+
crate::mir::ReturnConstraint,
1337+
}
13351338

13361339
macro_rules! sty_debug_print {
13371340
($fmt: expr, $ctxt: expr, $($variant: ident),*) => {{

compiler/rustc_middle/src/ty/structural_impls.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ TrivialTypeTraversalAndLiftImpls! {
276276
}
277277

278278
TrivialTypeTraversalAndLiftImpls! {
279-
for<'tcx> {
280-
ty::ValTree<'tcx>,
281-
}
279+
ty::ValTree<'tcx>,
282280
}
283281

284282
///////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)