Skip to content

Commit db8fe2b

Browse files
committed
Remove more unused Lift impls.
1 parent 41d8b90 commit db8fe2b

File tree

12 files changed

+36
-137
lines changed

12 files changed

+36
-137
lines changed

compiler/rustc_infer/src/infer/free_regions.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! and use that to decide when one free region outlives another, and so forth.
55
66
use rustc_data_structures::transitive_relation::TransitiveRelation;
7-
use rustc_middle::ty::{Lift, Region, TyCtxt};
7+
use rustc_middle::ty::{Region, TyCtxt};
88

99
/// Combines a `FreeRegionMap` and a `TyCtxt`.
1010
///
@@ -101,10 +101,3 @@ impl<'tcx> FreeRegionMap<'tcx> {
101101
result
102102
}
103103
}
104-
105-
impl<'a, 'tcx> Lift<'tcx> for FreeRegionMap<'a> {
106-
type Lifted = FreeRegionMap<'tcx>;
107-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<FreeRegionMap<'tcx>> {
108-
self.relation.maybe_map(|fr| tcx.lift(fr)).map(|relation| FreeRegionMap { relation })
109-
}
110-
}

compiler/rustc_middle/src/infer/canonical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl<'tcx, V> Canonical<'tcx, V> {
432432
pub type QueryOutlivesConstraint<'tcx> =
433433
(ty::OutlivesPredicate<GenericArg<'tcx>, Region<'tcx>>, ConstraintCategory<'tcx>);
434434

435-
TrivialTypeTraversalAndLiftImpls! {
435+
TrivialTypeTraversalImpls! {
436436
crate::infer::canonical::Certainty,
437437
crate::infer::canonical::CanonicalTyVarKind,
438438
}

compiler/rustc_middle/src/mir/basic_blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<'tcx> graph::WithPredecessors for BasicBlocks<'tcx> {
178178
}
179179
}
180180

181-
TrivialTypeTraversalAndLiftImpls! { Cache }
181+
TrivialTypeTraversalImpls! { Cache }
182182

183183
impl<S: Encoder> Encodable<S> for Cache {
184184
#[inline]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Into<ErrorGuaranteed> for ReportedErrorInfo {
6767
}
6868
}
6969

70-
TrivialTypeTraversalAndLiftImpls! { ErrorHandled }
70+
TrivialTypeTraversalImpls! { ErrorHandled }
7171

7272
pub type EvalToAllocationRawResult<'tcx> = Result<ConstAlloc<'tcx>, ErrorHandled>;
7373
pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ pub enum BindingForm<'tcx> {
707707
RefForGuard,
708708
}
709709

710-
TrivialTypeTraversalAndLiftImpls! { BindingForm<'tcx> }
710+
TrivialTypeTraversalImpls! { BindingForm<'tcx> }
711711

712712
mod binding_form_impl {
713713
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};

compiler/rustc_middle/src/mir/type_foldable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_ast::InlineAsmTemplatePiece;
55
use super::*;
66
use crate::ty;
77

8-
TrivialTypeTraversalAndLiftImpls! {
8+
TrivialTypeTraversalImpls! {
99
BlockTailInfo,
1010
MirPhase,
1111
SourceInfo,

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::infer::canonical::Canonical;
1313
use crate::mir::ConstraintCategory;
1414
use crate::ty::abstract_const::NotConstEvaluatable;
1515
use crate::ty::GenericArgsRef;
16-
use crate::ty::{self, AdtKind, Ty, TyCtxt};
16+
use crate::ty::{self, AdtKind, Ty};
1717

1818
use rustc_data_structures::sync::Lrc;
1919
use rustc_errors::{Applicability, Diagnostic};
@@ -524,13 +524,6 @@ pub enum StatementAsExpression {
524524
NeedsBoxing,
525525
}
526526

527-
impl<'tcx> ty::Lift<'tcx> for StatementAsExpression {
528-
type Lifted = StatementAsExpression;
529-
fn lift_to_tcx(self, _tcx: TyCtxt<'tcx>) -> Option<StatementAsExpression> {
530-
Some(self)
531-
}
532-
}
533-
534527
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
535528
#[derive(TypeVisitable, TypeFoldable)]
536529
pub struct MatchExpressionArmCause<'tcx> {
@@ -736,7 +729,7 @@ pub enum BuiltinImplSource {
736729
TupleUnsizing,
737730
}
738731

739-
TrivialTypeTraversalAndLiftImpls! { BuiltinImplSource }
732+
TrivialTypeTraversalImpls! { BuiltinImplSource }
740733

741734
#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
742735
pub enum ObjectSafetyViolation {

compiler/rustc_middle/src/traits/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl From<ErrorGuaranteed> for OverflowError {
305305
}
306306
}
307307

308-
TrivialTypeTraversalAndLiftImpls! { OverflowError }
308+
TrivialTypeTraversalImpls! { OverflowError }
309309

310310
impl<'tcx> From<OverflowError> for SelectionError<'tcx> {
311311
fn from(overflow_error: OverflowError) -> SelectionError<'tcx> {

compiler/rustc_middle/src/ty/abstract_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl From<ErrorGuaranteed> for NotConstEvaluatable {
2727
}
2828
}
2929

30-
TrivialTypeTraversalAndLiftImpls! { NotConstEvaluatable }
30+
TrivialTypeTraversalImpls! { NotConstEvaluatable }
3131

3232
pub type BoundAbstractConst<'tcx> = Result<Option<EarlyBinder<ty::Const<'tcx>>>, ErrorGuaranteed>;
3333

compiler/rustc_middle/src/ty/binding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub enum BindingMode {
66
BindByValue(Mutability),
77
}
88

9-
TrivialTypeTraversalAndLiftImpls! { BindingMode }
9+
TrivialTypeTraversalImpls! { BindingMode }
1010

1111
impl BindingMode {
1212
pub fn convert(BindingAnnotation(by_ref, mutbl): BindingAnnotation) -> BindingMode {

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
5050
use rustc_hir::definitions::Definitions;
5151
use rustc_hir::intravisit::Visitor;
5252
use rustc_hir::lang_items::LangItem;
53-
use rustc_hir::{Constness, HirId, Node, TraitCandidate};
53+
use rustc_hir::{HirId, Node, TraitCandidate};
5454
use rustc_index::IndexVec;
5555
use rustc_macros::HashStable;
5656
use rustc_query_system::dep_graph::DepNodeIndex;
@@ -1251,19 +1251,13 @@ nop_lift! {predicate; Clause<'a> => Clause<'tcx>}
12511251

12521252
nop_list_lift! {type_lists; Ty<'a> => Ty<'tcx>}
12531253
nop_list_lift! {poly_existential_predicates; PolyExistentialPredicate<'a> => PolyExistentialPredicate<'tcx>}
1254-
nop_list_lift! {clauses; Clause<'a> => Clause<'tcx>}
1255-
nop_list_lift! {canonical_var_infos; CanonicalVarInfo<'a> => CanonicalVarInfo<'tcx>}
1256-
nop_list_lift! {projs; ProjectionKind => ProjectionKind}
12571254
nop_list_lift! {bound_variable_kinds; ty::BoundVariableKind => ty::BoundVariableKind}
12581255

12591256
// This is the impl for `&'a GenericArgs<'a>`.
12601257
nop_list_lift! {args; GenericArg<'a> => GenericArg<'tcx>}
12611258

12621259
TrivialLiftImpls! {
1263-
Constness,
1264-
traits::WellFormedLoc,
12651260
ImplPolarity,
1266-
crate::mir::ReturnConstraint,
12671261
}
12681262

12691263
macro_rules! sty_debug_print {

compiler/rustc_middle/src/ty/structural_impls.rs

Lines changed: 24 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer};
99
use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
1010
use crate::ty::{self, AliasTy, InferConst, Lift, Term, TermKind, Ty, TyCtxt};
1111
use rustc_hir::def::Namespace;
12-
use rustc_index::{Idx, IndexVec};
1312
use rustc_target::abi::TyAndLayout;
1413
use rustc_type_ir::{ConstKind, DebugWithInfcx, InferCtxtLike, OptWithInfcx};
1514

1615
use std::fmt::{self, Debug};
1716
use std::ops::ControlFlow;
18-
use std::rc::Rc;
19-
use std::sync::Arc;
2017

2118
use super::{GenericArg, GenericArgKind, Region};
2219

@@ -443,21 +440,15 @@ impl<'tcx, T: DebugWithInfcx<TyCtxt<'tcx>>> DebugWithInfcx<TyCtxt<'tcx>> for ty:
443440
// For things for which the type library provides traversal implementations
444441
// for all Interners, we only need to provide a Lift implementation:
445442
TrivialLiftImpls! {
446-
(),
447-
bool,
448-
usize,
449-
u16,
450-
u32,
451-
u64,
452-
String,
453-
rustc_type_ir::DebruijnIndex,
454-
}
455-
456-
// For things about which the type library does not know, or does not
457-
// provide any traversal implementations, we need to provide both a Lift
458-
// implementation and traversal implementations (the latter only for
459-
// TyCtxt<'_> interners).
460-
TrivialTypeTraversalAndLiftImpls! {
443+
(),
444+
bool,
445+
usize,
446+
}
447+
448+
// For some things about which the type library does not know, or does not
449+
// provide any traversal implementations, we need to provide a traversal
450+
// implementation (only for TyCtxt<'_> interners).
451+
TrivialTypeTraversalImpls! {
461452
::rustc_target::abi::FieldIdx,
462453
::rustc_target::abi::VariantIdx,
463454
crate::middle::region::Scope,
@@ -467,14 +458,10 @@ TrivialTypeTraversalAndLiftImpls! {
467458
::rustc_ast::NodeId,
468459
::rustc_span::symbol::Symbol,
469460
::rustc_hir::def::Res,
470-
::rustc_hir::def_id::DefId,
471461
::rustc_hir::def_id::LocalDefId,
472462
::rustc_hir::HirId,
473463
::rustc_hir::MatchSource,
474-
::rustc_hir::Mutability,
475-
::rustc_hir::Unsafety,
476464
::rustc_target::asm::InlineAsmRegOrRegClass,
477-
::rustc_target::spec::abi::Abi,
478465
crate::mir::coverage::CounterId,
479466
crate::mir::coverage::ExpressionId,
480467
crate::mir::coverage::MappedExpressionIndex,
@@ -492,103 +479,42 @@ TrivialTypeTraversalAndLiftImpls! {
492479
crate::ty::AssocItem,
493480
crate::ty::AssocKind,
494481
crate::ty::AliasKind,
495-
crate::ty::AliasRelationDirection,
496482
crate::ty::Placeholder<crate::ty::BoundRegion>,
497483
crate::ty::Placeholder<crate::ty::BoundTy>,
498484
crate::ty::Placeholder<ty::BoundVar>,
499-
crate::ty::ClosureKind,
500485
crate::ty::FreeRegion,
501486
crate::ty::InferTy,
502487
crate::ty::IntVarValue,
503-
crate::ty::ParamConst,
504-
crate::ty::ParamTy,
505488
crate::ty::adjustment::PointerCoercion,
506489
crate::ty::RegionVid,
507490
crate::ty::UniverseIndex,
508491
crate::ty::Variance,
509492
::rustc_span::Span,
510493
::rustc_span::symbol::Ident,
511494
::rustc_errors::ErrorGuaranteed,
512-
interpret::Scalar,
513-
rustc_target::abi::Size,
514495
ty::BoundVar,
496+
ty::ValTree<'tcx>,
515497
}
516-
498+
// For some things about which the type library does not know, or does not
499+
// provide any traversal implementations, we need to provide a traversal
500+
// implementation and a lift implementation (the former only for TyCtxt<'_>
501+
// interners).
517502
TrivialTypeTraversalAndLiftImpls! {
518-
ty::ValTree<'tcx>,
503+
::rustc_hir::def_id::DefId,
504+
::rustc_hir::Mutability,
505+
::rustc_hir::Unsafety,
506+
::rustc_target::spec::abi::Abi,
507+
crate::ty::AliasRelationDirection,
508+
crate::ty::ClosureKind,
509+
crate::ty::ParamConst,
510+
crate::ty::ParamTy,
511+
interpret::Scalar,
512+
rustc_target::abi::Size,
519513
}
520514

521515
///////////////////////////////////////////////////////////////////////////
522516
// Lift implementations
523517

524-
impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) {
525-
type Lifted = (A::Lifted, B::Lifted);
526-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
527-
Some((tcx.lift(self.0)?, tcx.lift(self.1)?))
528-
}
529-
}
530-
531-
impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>, C: Lift<'tcx>> Lift<'tcx> for (A, B, C) {
532-
type Lifted = (A::Lifted, B::Lifted, C::Lifted);
533-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
534-
Some((tcx.lift(self.0)?, tcx.lift(self.1)?, tcx.lift(self.2)?))
535-
}
536-
}
537-
538-
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Option<T> {
539-
type Lifted = Option<T::Lifted>;
540-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
541-
Some(match self {
542-
Some(x) => Some(tcx.lift(x)?),
543-
None => None,
544-
})
545-
}
546-
}
547-
548-
impl<'tcx, T: Lift<'tcx>, E: Lift<'tcx>> Lift<'tcx> for Result<T, E> {
549-
type Lifted = Result<T::Lifted, E::Lifted>;
550-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
551-
match self {
552-
Ok(x) => tcx.lift(x).map(Ok),
553-
Err(e) => tcx.lift(e).map(Err),
554-
}
555-
}
556-
}
557-
558-
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Box<T> {
559-
type Lifted = Box<T::Lifted>;
560-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
561-
Some(Box::new(tcx.lift(*self)?))
562-
}
563-
}
564-
565-
impl<'tcx, T: Lift<'tcx> + Clone> Lift<'tcx> for Rc<T> {
566-
type Lifted = Rc<T::Lifted>;
567-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
568-
Some(Rc::new(tcx.lift(self.as_ref().clone())?))
569-
}
570-
}
571-
572-
impl<'tcx, T: Lift<'tcx> + Clone> Lift<'tcx> for Arc<T> {
573-
type Lifted = Arc<T::Lifted>;
574-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
575-
Some(Arc::new(tcx.lift(self.as_ref().clone())?))
576-
}
577-
}
578-
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Vec<T> {
579-
type Lifted = Vec<T::Lifted>;
580-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
581-
self.into_iter().map(|v| tcx.lift(v)).collect()
582-
}
583-
}
584-
585-
impl<'tcx, I: Idx, T: Lift<'tcx>> Lift<'tcx> for IndexVec<I, T> {
586-
type Lifted = IndexVec<I, T::Lifted>;
587-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
588-
self.into_iter().map(|e| tcx.lift(e)).collect()
589-
}
590-
}
591-
592518
impl<'a, 'tcx> Lift<'tcx> for Term<'a> {
593519
type Lifted = ty::Term<'tcx>;
594520
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
@@ -601,13 +527,6 @@ impl<'a, 'tcx> Lift<'tcx> for Term<'a> {
601527
)
602528
}
603529
}
604-
impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> {
605-
type Lifted = ty::ParamEnv<'tcx>;
606-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
607-
tcx.lift(self.caller_bounds())
608-
.map(|caller_bounds| ty::ParamEnv::new(caller_bounds, self.reveal()))
609-
}
610-
}
611530

612531
///////////////////////////////////////////////////////////////////////////
613532
// Traversal implementations.

0 commit comments

Comments
 (0)