Skip to content

Commit abe2a68

Browse files
committed
Remove more unused Lift impls.
1 parent af7d3e5 commit abe2a68

File tree

12 files changed

+37
-128
lines changed

12 files changed

+37
-128
lines changed

Diff for: compiler/rustc_infer/src/infer/free_regions.rs

+1-8
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-
}

Diff for: compiler/rustc_middle/src/infer/canonical.rs

+1-1
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
}

Diff for: compiler/rustc_middle/src/mir/basic_blocks.rs

+1-1
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]

Diff for: compiler/rustc_middle/src/mir/interpret/error.rs

+1-1
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>;

Diff for: compiler/rustc_middle/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ pub enum BindingForm<'tcx> {
744744
RefForGuard,
745745
}
746746

747-
TrivialTypeTraversalAndLiftImpls! { BindingForm<'tcx> }
747+
TrivialTypeTraversalImpls! { BindingForm<'tcx> }
748748

749749
mod binding_form_impl {
750750
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};

Diff for: compiler/rustc_middle/src/mir/type_foldable.rs

+1-1
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,

Diff for: compiler/rustc_middle/src/traits/mod.rs

+2-9
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 {

Diff for: compiler/rustc_middle/src/traits/select.rs

+1-1
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> {

Diff for: compiler/rustc_middle/src/ty/abstract_const.rs

+1-1
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

Diff for: compiler/rustc_middle/src/ty/binding.rs

+1-1
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 {

Diff for: compiler/rustc_middle/src/ty/context.rs

+1-7
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 {

Diff for: compiler/rustc_middle/src/ty/structural_impls.rs

+25-96
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::print::PrettyPrinter;
2219
use super::{GenericArg, GenericArgKind, Region};
@@ -457,21 +454,15 @@ impl<'tcx, T: DebugWithInfcx<TyCtxt<'tcx>>> DebugWithInfcx<TyCtxt<'tcx>> for ty:
457454
// For things for which the type library provides traversal implementations
458455
// for all Interners, we only need to provide a Lift implementation:
459456
TrivialLiftImpls! {
460-
(),
461-
bool,
462-
usize,
463-
u16,
464-
u32,
465-
u64,
466-
String,
467-
rustc_type_ir::DebruijnIndex,
468-
}
469-
470-
// For things about which the type library does not know, or does not
471-
// provide any traversal implementations, we need to provide both a Lift
472-
// implementation and traversal implementations (the latter only for
473-
// TyCtxt<'_> interners).
474-
TrivialTypeTraversalAndLiftImpls! {
457+
(),
458+
bool,
459+
usize,
460+
}
461+
462+
// For some things about which the type library does not know, or does not
463+
// provide any traversal implementations, we need to provide a traversal
464+
// implementation (only for TyCtxt<'_> interners).
465+
TrivialTypeTraversalImpls! {
475466
::rustc_target::abi::FieldIdx,
476467
::rustc_target::abi::VariantIdx,
477468
crate::middle::region::Scope,
@@ -481,14 +472,10 @@ TrivialTypeTraversalAndLiftImpls! {
481472
::rustc_ast::NodeId,
482473
::rustc_span::symbol::Symbol,
483474
::rustc_hir::def::Res,
484-
::rustc_hir::def_id::DefId,
485475
::rustc_hir::def_id::LocalDefId,
486476
::rustc_hir::HirId,
487477
::rustc_hir::MatchSource,
488-
::rustc_hir::Mutability,
489-
::rustc_hir::Unsafety,
490478
::rustc_target::asm::InlineAsmRegOrRegClass,
491-
::rustc_target::spec::abi::Abi,
492479
crate::mir::coverage::CounterId,
493480
crate::mir::coverage::ExpressionId,
494481
crate::mir::coverage::MappedExpressionIndex,
@@ -506,50 +493,43 @@ TrivialTypeTraversalAndLiftImpls! {
506493
crate::ty::AssocItem,
507494
crate::ty::AssocKind,
508495
crate::ty::AliasKind,
509-
crate::ty::AliasRelationDirection,
510496
crate::ty::Placeholder<crate::ty::BoundRegion>,
511497
crate::ty::Placeholder<crate::ty::BoundTy>,
512498
crate::ty::Placeholder<ty::BoundVar>,
513-
crate::ty::ClosureKind,
514499
crate::ty::FreeRegion,
515500
crate::ty::InferTy,
516501
crate::ty::IntVarValue,
517-
crate::ty::ParamConst,
518-
crate::ty::ParamTy,
519502
crate::ty::adjustment::PointerCoercion,
520503
crate::ty::RegionVid,
521504
crate::ty::UniverseIndex,
522505
crate::ty::Variance,
523506
::rustc_span::Span,
524507
::rustc_span::symbol::Ident,
525508
::rustc_errors::ErrorGuaranteed,
526-
interpret::Scalar,
527-
interpret::AllocId,
528-
rustc_target::abi::Size,
529509
ty::BoundVar,
510+
ty::ValTree<'tcx>,
530511
}
531-
512+
// For some things about which the type library does not know, or does not
513+
// provide any traversal implementations, we need to provide a traversal
514+
// implementation and a lift implementation (the former only for TyCtxt<'_>
515+
// interners).
532516
TrivialTypeTraversalAndLiftImpls! {
533-
ty::ValTree<'tcx>,
517+
::rustc_hir::def_id::DefId,
518+
::rustc_hir::Mutability,
519+
::rustc_hir::Unsafety,
520+
::rustc_target::spec::abi::Abi,
521+
crate::ty::AliasRelationDirection,
522+
crate::ty::ClosureKind,
523+
crate::ty::ParamConst,
524+
crate::ty::ParamTy,
525+
interpret::Scalar,
526+
interpret::AllocId,
527+
rustc_target::abi::Size,
534528
}
535529

536530
///////////////////////////////////////////////////////////////////////////
537531
// Lift implementations
538532

539-
impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) {
540-
type Lifted = (A::Lifted, B::Lifted);
541-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
542-
Some((tcx.lift(self.0)?, tcx.lift(self.1)?))
543-
}
544-
}
545-
546-
impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>, C: Lift<'tcx>> Lift<'tcx> for (A, B, C) {
547-
type Lifted = (A::Lifted, B::Lifted, C::Lifted);
548-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
549-
Some((tcx.lift(self.0)?, tcx.lift(self.1)?, tcx.lift(self.2)?))
550-
}
551-
}
552-
553533
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Option<T> {
554534
type Lifted = Option<T::Lifted>;
555535
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
@@ -560,50 +540,6 @@ impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Option<T> {
560540
}
561541
}
562542

563-
impl<'tcx, T: Lift<'tcx>, E: Lift<'tcx>> Lift<'tcx> for Result<T, E> {
564-
type Lifted = Result<T::Lifted, E::Lifted>;
565-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
566-
match self {
567-
Ok(x) => tcx.lift(x).map(Ok),
568-
Err(e) => tcx.lift(e).map(Err),
569-
}
570-
}
571-
}
572-
573-
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Box<T> {
574-
type Lifted = Box<T::Lifted>;
575-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
576-
Some(Box::new(tcx.lift(*self)?))
577-
}
578-
}
579-
580-
impl<'tcx, T: Lift<'tcx> + Clone> Lift<'tcx> for Rc<T> {
581-
type Lifted = Rc<T::Lifted>;
582-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
583-
Some(Rc::new(tcx.lift(self.as_ref().clone())?))
584-
}
585-
}
586-
587-
impl<'tcx, T: Lift<'tcx> + Clone> Lift<'tcx> for Arc<T> {
588-
type Lifted = Arc<T::Lifted>;
589-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
590-
Some(Arc::new(tcx.lift(self.as_ref().clone())?))
591-
}
592-
}
593-
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Vec<T> {
594-
type Lifted = Vec<T::Lifted>;
595-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
596-
self.into_iter().map(|v| tcx.lift(v)).collect()
597-
}
598-
}
599-
600-
impl<'tcx, I: Idx, T: Lift<'tcx>> Lift<'tcx> for IndexVec<I, T> {
601-
type Lifted = IndexVec<I, T::Lifted>;
602-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
603-
self.into_iter().map(|e| tcx.lift(e)).collect()
604-
}
605-
}
606-
607543
impl<'a, 'tcx> Lift<'tcx> for Term<'a> {
608544
type Lifted = ty::Term<'tcx>;
609545
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
@@ -616,13 +552,6 @@ impl<'a, 'tcx> Lift<'tcx> for Term<'a> {
616552
)
617553
}
618554
}
619-
impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> {
620-
type Lifted = ty::ParamEnv<'tcx>;
621-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
622-
tcx.lift(self.caller_bounds())
623-
.map(|caller_bounds| ty::ParamEnv::new(caller_bounds, self.reveal()))
624-
}
625-
}
626555

627556
///////////////////////////////////////////////////////////////////////////
628557
// Traversal implementations.

0 commit comments

Comments
 (0)