Skip to content

Commit 24bb884

Browse files
committed
Auto merge of #115831 - nnethercote:remove-unused-Lift-impls, r=bjorn3
Remove unused `Lift` impls r? `@bjorn3`
2 parents df99bc1 + abe2a68 commit 24bb884

File tree

31 files changed

+108
-212
lines changed

31 files changed

+108
-212
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/region_name.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
442442
span: Span,
443443
counter: usize,
444444
) -> RegionNameHighlight {
445-
let mut highlight = RegionHighlightMode::new(self.infcx.tcx);
446-
highlight.highlighting_region_vid(needle_fr, counter);
445+
let mut highlight = RegionHighlightMode::default();
446+
highlight.highlighting_region_vid(self.infcx.tcx, needle_fr, counter);
447447
let type_name =
448448
self.infcx.extract_inference_diagnostics_data(ty.into(), Some(highlight)).name;
449449

@@ -804,8 +804,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
804804
return None;
805805
}
806806

807-
let mut highlight = RegionHighlightMode::new(tcx);
808-
highlight.highlighting_region_vid(fr, *self.next_region_name.try_borrow().unwrap());
807+
let mut highlight = RegionHighlightMode::default();
808+
highlight.highlighting_region_vid(tcx, fr, *self.next_region_name.try_borrow().unwrap());
809809
let type_name =
810810
self.infcx.extract_inference_diagnostics_data(yield_ty.into(), Some(highlight)).name;
811811

Diff for: compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
385385

386386
let highlight_trait_ref = |trait_ref| Highlighted {
387387
tcx: self.tcx(),
388-
highlight: RegionHighlightMode::new(self.tcx()),
388+
highlight: RegionHighlightMode::default(),
389389
value: trait_ref,
390390
};
391391

Diff for: compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
6767
}
6868

6969
impl<'tcx> HighlightBuilder<'tcx> {
70-
fn build(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> RegionHighlightMode<'tcx> {
70+
fn build(ty: Ty<'tcx>) -> RegionHighlightMode<'tcx> {
7171
let mut builder =
72-
HighlightBuilder { highlight: RegionHighlightMode::new(tcx), counter: 1 };
72+
HighlightBuilder { highlight: RegionHighlightMode::default(), counter: 1 };
7373
builder.visit_ty(ty);
7474
builder.highlight
7575
}
@@ -85,12 +85,12 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
8585
}
8686
}
8787

88-
let expected_highlight = HighlightBuilder::build(self.tcx(), expected);
88+
let expected_highlight = HighlightBuilder::build(expected);
8989
let expected = self
9090
.cx
9191
.extract_inference_diagnostics_data(expected.into(), Some(expected_highlight))
9292
.name;
93-
let found_highlight = HighlightBuilder::build(self.tcx(), found);
93+
let found_highlight = HighlightBuilder::build(found);
9494
let found =
9595
self.cx.extract_inference_diagnostics_data(found.into(), Some(found_highlight)).name;
9696

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use std::ops::Index;
3434
/// variables have been rewritten to "canonical vars". These are
3535
/// numbered starting from 0 in order of first appearance.
3636
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable)]
37-
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
37+
#[derive(HashStable, TypeFoldable, TypeVisitable)]
3838
pub struct Canonical<'tcx, V> {
3939
pub value: V,
4040
pub max_universe: ty::UniverseIndex,
@@ -72,7 +72,7 @@ impl<'tcx> ty::TypeFoldable<TyCtxt<'tcx>> for CanonicalVarInfos<'tcx> {
7272
/// variables. You will need to supply it later to instantiate the
7373
/// canonicalized query response.
7474
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable)]
75-
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
75+
#[derive(HashStable, TypeFoldable, TypeVisitable)]
7676
pub struct CanonicalVarValues<'tcx> {
7777
pub var_values: ty::GenericArgsRef<'tcx>,
7878
}
@@ -311,7 +311,7 @@ pub enum CanonicalTyVarKind {
311311
/// After we execute a query with a canonicalized key, we get back a
312312
/// `Canonical<QueryResponse<..>>`. You can use
313313
/// `instantiate_query_result` to access the data in this result.
314-
#[derive(Clone, Debug, HashStable, TypeFoldable, TypeVisitable, Lift)]
314+
#[derive(Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
315315
pub struct QueryResponse<'tcx, R> {
316316
pub var_values: CanonicalVarValues<'tcx>,
317317
pub region_constraints: QueryRegionConstraints<'tcx>,
@@ -326,7 +326,7 @@ pub struct QueryResponse<'tcx, R> {
326326
}
327327

328328
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
329-
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
329+
#[derive(HashStable, TypeFoldable, TypeVisitable)]
330330
pub struct QueryRegionConstraints<'tcx> {
331331
pub outlives: Vec<QueryOutlivesConstraint<'tcx>>,
332332
pub member_constraints: Vec<MemberConstraint<'tcx>>,
@@ -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/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_span::Span;
1313
/// R0 member of [O1..On]
1414
/// ```
1515
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
16-
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
16+
#[derive(HashStable, TypeFoldable, TypeVisitable)]
1717
pub struct MemberConstraint<'tcx> {
1818
/// The `DefId` and args of the opaque type causing this constraint.
1919
/// Used for error reporting.

Diff for: compiler/rustc_middle/src/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ macro_rules! span_bug {
4242
// the impls for you.
4343

4444
#[macro_export]
45-
macro_rules! CloneLiftImpls {
45+
macro_rules! TrivialLiftImpls {
4646
($($ty:ty),+ $(,)?) => {
4747
$(
4848
impl<'tcx> $crate::ty::Lift<'tcx> for $ty {
@@ -96,6 +96,6 @@ macro_rules! TrivialTypeTraversalImpls {
9696
macro_rules! TrivialTypeTraversalAndLiftImpls {
9797
($($t:tt)*) => {
9898
TrivialTypeTraversalImpls! { $($t)* }
99-
CloneLiftImpls! { $($t)* }
99+
TrivialLiftImpls! { $($t)* }
100100
}
101101
}

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/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub use self::pointer::{Pointer, PointerArithmetic, Provenance};
162162
/// - A constant
163163
/// - A static
164164
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, TyEncodable, TyDecodable)]
165-
#[derive(HashStable, Lift, TypeFoldable, TypeVisitable)]
165+
#[derive(HashStable, TypeFoldable, TypeVisitable)]
166166
pub struct GlobalId<'tcx> {
167167
/// For a constant or static, the `Instance` of the item itself.
168168
/// For a promoted global, the `Instance` of the function they belong to.

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

+3-3
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};
@@ -2295,7 +2295,7 @@ pub struct Constant<'tcx> {
22952295
}
22962296

22972297
#[derive(Clone, Copy, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable, Debug)]
2298-
#[derive(Lift, TypeFoldable, TypeVisitable)]
2298+
#[derive(TypeFoldable, TypeVisitable)]
22992299
pub enum ConstantKind<'tcx> {
23002300
/// This constant came from the type system.
23012301
///
@@ -2615,7 +2615,7 @@ impl<'tcx> ConstantKind<'tcx> {
26152615
}
26162616

26172617
/// An unevaluated (potentially generic) constant used in MIR.
2618-
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable, Lift)]
2618+
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable)]
26192619
#[derive(Hash, HashStable, TypeFoldable, TypeVisitable)]
26202620
pub struct UnevaluatedConst<'tcx> {
26212621
pub def: DefId,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ rustc_data_structures::static_assert_size!(ConstraintCategory<'_>, 16);
334334
///
335335
/// See also `rustc_const_eval::borrow_check::constraints`.
336336
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
337-
#[derive(TyEncodable, TyDecodable, HashStable, Lift, TypeVisitable, TypeFoldable)]
337+
#[derive(TyEncodable, TyDecodable, HashStable, TypeVisitable, TypeFoldable)]
338338
pub enum ConstraintCategory<'tcx> {
339339
Return(ReturnConstraint),
340340
Yield,

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

+14-21
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};
@@ -86,7 +86,7 @@ pub enum Reveal {
8686
///
8787
/// We do not want to intern this as there are a lot of obligation causes which
8888
/// only live for a short period of time.
89-
#[derive(Clone, Debug, PartialEq, Eq, Lift, HashStable, TyEncodable, TyDecodable)]
89+
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
9090
#[derive(TypeVisitable, TypeFoldable)]
9191
pub struct ObligationCause<'tcx> {
9292
pub span: Span,
@@ -194,15 +194,15 @@ impl<'tcx> ObligationCause<'tcx> {
194194
}
195195
}
196196

197-
#[derive(Clone, Debug, PartialEq, Eq, Lift, HashStable, TyEncodable, TyDecodable)]
197+
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
198198
#[derive(TypeVisitable, TypeFoldable)]
199199
pub struct UnifyReceiverContext<'tcx> {
200200
pub assoc_item: ty::AssocItem,
201201
pub param_env: ty::ParamEnv<'tcx>,
202202
pub args: GenericArgsRef<'tcx>,
203203
}
204204

205-
#[derive(Clone, PartialEq, Eq, Lift, Default, HashStable)]
205+
#[derive(Clone, PartialEq, Eq, Default, HashStable)]
206206
#[derive(TypeVisitable, TypeFoldable, TyEncodable, TyDecodable)]
207207
pub struct InternedObligationCauseCode<'tcx> {
208208
/// `None` for `ObligationCauseCode::MiscObligation` (a common case, occurs ~60% of
@@ -238,7 +238,7 @@ impl<'tcx> std::ops::Deref for InternedObligationCauseCode<'tcx> {
238238
}
239239
}
240240

241-
#[derive(Clone, Debug, PartialEq, Eq, Lift, HashStable, TyEncodable, TyDecodable)]
241+
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
242242
#[derive(TypeVisitable, TypeFoldable)]
243243
pub enum ObligationCauseCode<'tcx> {
244244
/// Not well classified or should be obvious from the span.
@@ -470,7 +470,7 @@ pub enum WellFormedLoc {
470470
},
471471
}
472472

473-
#[derive(Clone, Debug, PartialEq, Eq, Lift, HashStable, TyEncodable, TyDecodable)]
473+
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
474474
#[derive(TypeVisitable, TypeFoldable)]
475475
pub struct ImplDerivedObligationCause<'tcx> {
476476
pub derived: DerivedObligationCause<'tcx>,
@@ -524,14 +524,7 @@ 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-
534-
#[derive(Clone, Debug, PartialEq, Eq, Lift, HashStable, TyEncodable, TyDecodable)]
527+
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
535528
#[derive(TypeVisitable, TypeFoldable)]
536529
pub struct MatchExpressionArmCause<'tcx> {
537530
pub arm_block_id: Option<hir::HirId>,
@@ -547,7 +540,7 @@ pub struct MatchExpressionArmCause<'tcx> {
547540
}
548541

549542
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
550-
#[derive(Lift, TypeFoldable, TypeVisitable, HashStable, TyEncodable, TyDecodable)]
543+
#[derive(TypeFoldable, TypeVisitable, HashStable, TyEncodable, TyDecodable)]
551544
pub struct IfExpressionCause<'tcx> {
552545
pub then_id: hir::HirId,
553546
pub else_id: hir::HirId,
@@ -557,7 +550,7 @@ pub struct IfExpressionCause<'tcx> {
557550
pub opt_suggest_box_span: Option<Span>,
558551
}
559552

560-
#[derive(Clone, Debug, PartialEq, Eq, Lift, HashStable, TyEncodable, TyDecodable)]
553+
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
561554
#[derive(TypeVisitable, TypeFoldable)]
562555
pub struct DerivedObligationCause<'tcx> {
563556
/// The trait predicate of the parent obligation that led to the
@@ -570,7 +563,7 @@ pub struct DerivedObligationCause<'tcx> {
570563
pub parent_code: InternedObligationCauseCode<'tcx>,
571564
}
572565

573-
#[derive(Clone, Debug, TypeVisitable, Lift)]
566+
#[derive(Clone, Debug, TypeVisitable)]
574567
pub enum SelectionError<'tcx> {
575568
/// The trait is not implemented.
576569
Unimplemented,
@@ -593,7 +586,7 @@ pub enum SelectionError<'tcx> {
593586
OpaqueTypeAutoTraitLeakageUnknown(DefId),
594587
}
595588

596-
#[derive(Clone, Debug, TypeVisitable, Lift)]
589+
#[derive(Clone, Debug, TypeVisitable)]
597590
pub struct SelectionOutputTypeParameterMismatch<'tcx> {
598591
pub found_trait_ref: ty::PolyTraitRef<'tcx>,
599592
pub expected_trait_ref: ty::PolyTraitRef<'tcx>,
@@ -638,7 +631,7 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
638631
/// ### The type parameter `N`
639632
///
640633
/// See explanation on `ImplSourceUserDefinedData`.
641-
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
634+
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
642635
#[derive(TypeFoldable, TypeVisitable)]
643636
pub enum ImplSource<'tcx, N> {
644637
/// ImplSource identifying a particular impl.
@@ -704,7 +697,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
704697
/// is `Obligation`, as one might expect. During codegen, however, this
705698
/// is `()`, because codegen only requires a shallow resolution of an
706699
/// impl, and nested obligations are satisfied later.
707-
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
700+
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
708701
#[derive(TypeFoldable, TypeVisitable)]
709702
pub struct ImplSourceUserDefinedData<'tcx, N> {
710703
pub impl_def_id: DefId,
@@ -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 {

0 commit comments

Comments
 (0)