Skip to content

Commit 854a710

Browse files
Rollup merge of #136563 - nnethercote:clean-up-Trivials, r=lcnr
Clean up `Trivial*Impls` macros They're currently quite messy. Details in the individual commit logs. r? `@lcnr`
2 parents 45398fc + d282a67 commit 854a710

File tree

11 files changed

+123
-164
lines changed

11 files changed

+123
-164
lines changed

compiler/rustc_middle/src/infer/canonical.rs

-4
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ impl<'tcx, R> QueryResponse<'tcx, R> {
142142
pub type QueryOutlivesConstraint<'tcx> =
143143
(ty::OutlivesPredicate<'tcx, GenericArg<'tcx>>, ConstraintCategory<'tcx>);
144144

145-
TrivialTypeTraversalImpls! {
146-
crate::infer::canonical::Certainty,
147-
}
148-
149145
#[derive(Default)]
150146
pub struct CanonicalParamEnvCache<'tcx> {
151147
map: Lock<

compiler/rustc_middle/src/mir/basic_blocks.rs

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ impl<'tcx> graph::Predecessors for BasicBlocks<'tcx> {
163163
}
164164
}
165165

166+
// Done here instead of in `structural_impls.rs` because `Cache` is private, as is `basic_blocks`.
166167
TrivialTypeTraversalImpls! { Cache }
167168

168169
impl<S: Encoder> Encodable<S> for Cache {

compiler/rustc_middle/src/mir/interpret/error.rs

-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ impl From<ReportedErrorInfo> for ErrorGuaranteed {
9595
}
9696
}
9797

98-
TrivialTypeTraversalImpls! { ErrorHandled }
99-
10098
pub type EvalToAllocationRawResult<'tcx> = Result<ConstAlloc<'tcx>, ErrorHandled>;
10199
pub type EvalStaticInitializerRawResult<'tcx> = Result<ConstAllocation<'tcx>, ErrorHandled>;
102100
pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;

compiler/rustc_middle/src/mir/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use self::visit::TyContext;
3434
use crate::mir::interpret::{AllocRange, Scalar};
3535
use crate::mir::visit::MirVisitable;
3636
use crate::ty::codec::{TyDecoder, TyEncoder};
37-
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
3837
use crate::ty::print::{FmtPrinter, Printer, pretty_print_const, with_no_trimmed_paths};
3938
use crate::ty::visit::TypeVisitableExt;
4039
use crate::ty::{
@@ -59,7 +58,6 @@ pub mod tcx;
5958
mod terminator;
6059

6160
pub mod traversal;
62-
mod type_foldable;
6361
pub mod visit;
6462

6563
pub use consts::*;
@@ -927,8 +925,6 @@ pub enum BindingForm<'tcx> {
927925
RefForGuard,
928926
}
929927

930-
TrivialTypeTraversalImpls! { BindingForm<'tcx> }
931-
932928
mod binding_form_impl {
933929
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
934930
use rustc_query_system::ich::StableHashingContext;

compiler/rustc_middle/src/mir/type_foldable.rs

-67
This file was deleted.

compiler/rustc_middle/src/traits/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,6 @@ pub enum IsConstable {
427427
Ctor,
428428
}
429429

430-
TrivialTypeTraversalAndLiftImpls! {
431-
IsConstable,
432-
}
433-
434430
/// The 'location' at which we try to perform HIR-based wf checking.
435431
/// This information is used to obtain an `hir::Ty`, which
436432
/// we can walk in order to obtain precise spans for any

compiler/rustc_middle/src/traits/select.rs

-2
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ impl From<ErrorGuaranteed> for OverflowError {
260260
}
261261
}
262262

263-
TrivialTypeTraversalImpls! { OverflowError }
264-
265263
impl<'tcx> From<OverflowError> for SelectionError<'tcx> {
266264
fn from(overflow_error: OverflowError) -> SelectionError<'tcx> {
267265
match overflow_error {

compiler/rustc_middle/src/ty/abstract_const.rs

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ impl From<ErrorGuaranteed> for NotConstEvaluatable {
3030
}
3131
}
3232

33-
TrivialTypeTraversalImpls! { NotConstEvaluatable }
34-
3533
pub type BoundAbstractConst<'tcx> =
3634
Result<Option<EarlyBinder<'tcx, ty::Const<'tcx>>>, ErrorGuaranteed>;
3735

compiler/rustc_middle/src/ty/context.rs

+21-23
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ use crate::traits::solve::{
7676
};
7777
use crate::ty::predicate::ExistentialPredicateStableCmpExt as _;
7878
use crate::ty::{
79-
self, AdtDef, AdtDefData, AdtKind, Binder, BoundConstness, Clause, Clauses, Const, GenericArg,
80-
GenericArgs, GenericArgsRef, GenericParamDefKind, ImplPolarity, List, ListWithCachedTypeInfo,
81-
ParamConst, ParamTy, Pattern, PatternKind, PolyExistentialPredicate, PolyFnSig, Predicate,
82-
PredicateKind, PredicatePolarity, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty,
83-
TyKind, TyVid, Visibility,
79+
self, AdtDef, AdtDefData, AdtKind, Binder, Clause, Clauses, Const, GenericArg, GenericArgs,
80+
GenericArgsRef, GenericParamDefKind, List, ListWithCachedTypeInfo, ParamConst, ParamTy,
81+
Pattern, PatternKind, PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind,
82+
PredicatePolarity, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVid,
83+
Visibility,
8484
};
8585

8686
#[allow(rustc::usage_of_ty_tykind)]
@@ -2243,21 +2243,23 @@ macro_rules! nop_list_lift {
22432243
};
22442244
}
22452245

2246-
nop_lift! {type_; Ty<'a> => Ty<'tcx>}
2247-
nop_lift! {region; Region<'a> => Region<'tcx>}
2248-
nop_lift! {const_; Const<'a> => Const<'tcx>}
2249-
nop_lift! {pat; Pattern<'a> => Pattern<'tcx>}
2250-
nop_lift! {const_allocation; ConstAllocation<'a> => ConstAllocation<'tcx>}
2251-
nop_lift! {predicate; Predicate<'a> => Predicate<'tcx>}
2252-
nop_lift! {predicate; Clause<'a> => Clause<'tcx>}
2253-
nop_lift! {layout; Layout<'a> => Layout<'tcx>}
2254-
2255-
nop_list_lift! {type_lists; Ty<'a> => Ty<'tcx>}
2256-
nop_list_lift! {poly_existential_predicates; PolyExistentialPredicate<'a> => PolyExistentialPredicate<'tcx>}
2257-
nop_list_lift! {bound_variable_kinds; ty::BoundVariableKind => ty::BoundVariableKind}
2246+
nop_lift! { type_; Ty<'a> => Ty<'tcx> }
2247+
nop_lift! { region; Region<'a> => Region<'tcx> }
2248+
nop_lift! { const_; Const<'a> => Const<'tcx> }
2249+
nop_lift! { pat; Pattern<'a> => Pattern<'tcx> }
2250+
nop_lift! { const_allocation; ConstAllocation<'a> => ConstAllocation<'tcx> }
2251+
nop_lift! { predicate; Predicate<'a> => Predicate<'tcx> }
2252+
nop_lift! { predicate; Clause<'a> => Clause<'tcx> }
2253+
nop_lift! { layout; Layout<'a> => Layout<'tcx> }
2254+
2255+
nop_list_lift! { type_lists; Ty<'a> => Ty<'tcx> }
2256+
nop_list_lift! {
2257+
poly_existential_predicates; PolyExistentialPredicate<'a> => PolyExistentialPredicate<'tcx>
2258+
}
2259+
nop_list_lift! { bound_variable_kinds; ty::BoundVariableKind => ty::BoundVariableKind }
22582260

22592261
// This is the impl for `&'a GenericArgs<'a>`.
2260-
nop_list_lift! {args; GenericArg<'a> => GenericArg<'tcx>}
2262+
nop_list_lift! { args; GenericArg<'a> => GenericArg<'tcx> }
22612263

22622264
macro_rules! nop_slice_lift {
22632265
($ty:ty => $lifted:ty) => {
@@ -2277,11 +2279,7 @@ macro_rules! nop_slice_lift {
22772279
};
22782280
}
22792281

2280-
nop_slice_lift! {ty::ValTree<'a> => ty::ValTree<'tcx>}
2281-
2282-
TrivialLiftImpls! {
2283-
ImplPolarity, PredicatePolarity, Promoted, BoundConstness,
2284-
}
2282+
nop_slice_lift! { ty::ValTree<'a> => ty::ValTree<'tcx> }
22852283

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

0 commit comments

Comments
 (0)