Skip to content

Commit 033d1df

Browse files
committed
Retire BraceStructLiftImpl.
1 parent 2add207 commit 033d1df

File tree

19 files changed

+26
-196
lines changed

19 files changed

+26
-196
lines changed

src/librustc/infer/canonical/mod.rs

+5-33
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use std::ops::Index;
3232
use syntax::source_map::Span;
3333
use crate::ty::fold::TypeFoldable;
3434
use crate::ty::subst::GenericArg;
35-
use crate::ty::{self, BoundVar, Lift, List, Region, TyCtxt};
35+
use crate::ty::{self, BoundVar, List, Region, TyCtxt};
3636

3737
mod canonicalizer;
3838

@@ -44,7 +44,7 @@ mod substitute;
4444
/// variables have been rewritten to "canonical vars". These are
4545
/// numbered starting from 0 in order of first appearance.
4646
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)]
47-
#[derive(HashStable, TypeFoldable)]
47+
#[derive(HashStable, TypeFoldable, Lift)]
4848
pub struct Canonical<'tcx, V> {
4949
pub max_universe: ty::UniverseIndex,
5050
pub variables: CanonicalVarInfos<'tcx>,
@@ -65,7 +65,7 @@ impl<'tcx> UseSpecializedDecodable for CanonicalVarInfos<'tcx> {}
6565
/// variables. You will need to supply it later to instantiate the
6666
/// canonicalized query response.
6767
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)]
68-
#[derive(HashStable, TypeFoldable)]
68+
#[derive(HashStable, TypeFoldable, Lift)]
6969
pub struct CanonicalVarValues<'tcx> {
7070
pub var_values: IndexVec<BoundVar, GenericArg<'tcx>>,
7171
}
@@ -188,15 +188,15 @@ pub enum CanonicalTyVarKind {
188188
/// After we execute a query with a canonicalized key, we get back a
189189
/// `Canonical<QueryResponse<..>>`. You can use
190190
/// `instantiate_query_result` to access the data in this result.
191-
#[derive(Clone, Debug, HashStable, TypeFoldable)]
191+
#[derive(Clone, Debug, HashStable, TypeFoldable, Lift)]
192192
pub struct QueryResponse<'tcx, R> {
193193
pub var_values: CanonicalVarValues<'tcx>,
194194
pub region_constraints: QueryRegionConstraints<'tcx>,
195195
pub certainty: Certainty,
196196
pub value: R,
197197
}
198198

199-
#[derive(Clone, Debug, Default, HashStable, TypeFoldable)]
199+
#[derive(Clone, Debug, Default, HashStable, TypeFoldable, Lift)]
200200
pub struct QueryRegionConstraints<'tcx> {
201201
pub outlives: Vec<QueryOutlivesConstraint<'tcx>>,
202202
pub member_constraints: Vec<MemberConstraint<'tcx>>,
@@ -469,13 +469,6 @@ CloneTypeFoldableImpls! {
469469
}
470470
}
471471

472-
BraceStructLiftImpl! {
473-
impl<'a, 'tcx, T> Lift<'tcx> for Canonical<'a, T> {
474-
type Lifted = Canonical<'tcx, T::Lifted>;
475-
max_universe, variables, value
476-
} where T: Lift<'tcx>
477-
}
478-
479472
impl<'tcx> CanonicalVarValues<'tcx> {
480473
pub fn len(&self) -> usize {
481474
self.var_values.len()
@@ -521,27 +514,6 @@ impl<'a, 'tcx> IntoIterator for &'a CanonicalVarValues<'tcx> {
521514
}
522515
}
523516

524-
BraceStructLiftImpl! {
525-
impl<'a, 'tcx> Lift<'tcx> for CanonicalVarValues<'a> {
526-
type Lifted = CanonicalVarValues<'tcx>;
527-
var_values,
528-
}
529-
}
530-
531-
BraceStructLiftImpl! {
532-
impl<'a, 'tcx, R> Lift<'tcx> for QueryResponse<'a, R> {
533-
type Lifted = QueryResponse<'tcx, R::Lifted>;
534-
var_values, region_constraints, certainty, value
535-
} where R: Lift<'tcx>
536-
}
537-
538-
BraceStructLiftImpl! {
539-
impl<'a, 'tcx> Lift<'tcx> for QueryRegionConstraints<'a> {
540-
type Lifted = QueryRegionConstraints<'tcx>;
541-
outlives, member_constraints
542-
}
543-
}
544-
545517
impl<'tcx> Index<BoundVar> for CanonicalVarValues<'tcx> {
546518
type Output = GenericArg<'tcx>;
547519

src/librustc/infer/region_constraints/mod.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl Constraint<'_> {
151151
/// ```
152152
/// R0 member of [O1..On]
153153
/// ```
154-
#[derive(Debug, Clone, HashStable, TypeFoldable)]
154+
#[derive(Debug, Clone, HashStable, TypeFoldable, Lift)]
155155
pub struct MemberConstraint<'tcx> {
156156
/// The `DefId` of the opaque type causing this constraint: used for error reporting.
157157
pub opaque_type_def_id: DefId,
@@ -169,13 +169,6 @@ pub struct MemberConstraint<'tcx> {
169169
pub choice_regions: Lrc<Vec<Region<'tcx>>>,
170170
}
171171

172-
BraceStructLiftImpl! {
173-
impl<'a, 'tcx> Lift<'tcx> for MemberConstraint<'a> {
174-
type Lifted = MemberConstraint<'tcx>;
175-
opaque_type_def_id, definition_span, hidden_ty, member_region, choice_regions
176-
}
177-
}
178-
179172
/// `VerifyGenericBound(T, _, R, RS)`: the parameter type `T` (or
180173
/// associated type) must outlive the region `R`. `T` is known to
181174
/// outlive `RS`. Therefore, verify that `R <= RS[i]` for some

src/librustc/macros.rs

-19
Original file line numberDiff line numberDiff line change
@@ -253,25 +253,6 @@ macro_rules! CloneTypeFoldableAndLiftImpls {
253253
}
254254
}
255255

256-
#[macro_export]
257-
macro_rules! BraceStructLiftImpl {
258-
(impl<$($p:tt),*> Lift<$tcx:tt> for $s:path {
259-
type Lifted = $lifted:ty;
260-
$($field:ident),* $(,)?
261-
} $(where $($wc:tt)*)*) => {
262-
impl<$($p),*> $crate::ty::Lift<$tcx> for $s
263-
$(where $($wc)*)*
264-
{
265-
type Lifted = $lifted;
266-
267-
fn lift_to_tcx(&self, tcx: TyCtxt<$tcx>) -> Option<$lifted> {
268-
$(let $field = tcx.lift(&self.$field)?;)*
269-
Some(Self::Lifted { $($field),* })
270-
}
271-
}
272-
};
273-
}
274-
275256
#[macro_export]
276257
macro_rules! EnumLiftImpl {
277258
(impl<$($p:tt),*> Lift<$tcx:tt> for $s:path {

src/librustc/mir/interpret/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ use rustc_macros::HashStable;
124124
use byteorder::{WriteBytesExt, ReadBytesExt, LittleEndian, BigEndian};
125125

126126
/// Uniquely identifies a specific constant or static.
127-
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, RustcEncodable, RustcDecodable, HashStable)]
127+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, RustcEncodable, RustcDecodable)]
128+
#[derive(HashStable, Lift)]
128129
pub struct GlobalId<'tcx> {
129130
/// For a constant or static, the `Instance` of the item itself.
130131
/// For a promoted global, the `Instance` of the function they belong to.

src/librustc/traits/query/dropck_outlives.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'cx, 'tcx> At<'cx, 'tcx> {
7979
}
8080
}
8181

82-
#[derive(Clone, Debug, Default, TypeFoldable)]
82+
#[derive(Clone, Debug, Default, TypeFoldable, Lift)]
8383
pub struct DropckOutlivesResult<'tcx> {
8484
pub kinds: Vec<GenericArg<'tcx>>,
8585
pub overflows: Vec<Ty<'tcx>>,
@@ -152,13 +152,6 @@ impl<'tcx> FromIterator<DtorckConstraint<'tcx>> for DtorckConstraint<'tcx> {
152152
result
153153
}
154154
}
155-
BraceStructLiftImpl! {
156-
impl<'a, 'tcx> Lift<'tcx> for DropckOutlivesResult<'a> {
157-
type Lifted = DropckOutlivesResult<'tcx>;
158-
kinds, overflows
159-
}
160-
}
161-
162155
impl_stable_hash_for!(struct DropckOutlivesResult<'tcx> {
163156
kinds, overflows
164157
});

src/librustc/traits/query/normalize.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'cx, 'tcx> At<'cx, 'tcx> {
6666
}
6767

6868
/// Result from the `normalize_projection_ty` query.
69-
#[derive(Clone, Debug, TypeFoldable)]
69+
#[derive(Clone, Debug, TypeFoldable, Lift)]
7070
pub struct NormalizationResult<'tcx> {
7171
/// Result of normalization.
7272
pub normalized_ty: Ty<'tcx>,
@@ -194,13 +194,6 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
194194
}
195195
}
196196

197-
BraceStructLiftImpl! {
198-
impl<'a, 'tcx> Lift<'tcx> for NormalizationResult<'a> {
199-
type Lifted = NormalizationResult<'tcx>;
200-
normalized_ty
201-
}
202-
}
203-
204197
impl_stable_hash_for!(struct NormalizationResult<'tcx> {
205198
normalized_ty
206199
});

src/librustc/traits/query/type_op/ascribe_user_type.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::hir::def_id::DefId;
44
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
55
use crate::ty::subst::UserSubsts;
66

7-
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable)]
7+
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable, Lift)]
88
pub struct AscribeUserType<'tcx> {
99
pub mir_ty: Ty<'tcx>,
1010
pub def_id: DefId,
@@ -39,13 +39,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> {
3939
}
4040
}
4141

42-
BraceStructLiftImpl! {
43-
impl<'a, 'tcx> Lift<'tcx> for AscribeUserType<'a> {
44-
type Lifted = AscribeUserType<'tcx>;
45-
mir_ty, def_id, user_substs
46-
}
47-
}
48-
4942
impl_stable_hash_for! {
5043
struct AscribeUserType<'tcx> {
5144
mir_ty, def_id, user_substs

src/librustc/traits/query/type_op/eq.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
44

5-
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable)]
5+
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable, Lift)]
66
pub struct Eq<'tcx> {
77
pub a: Ty<'tcx>,
88
pub b: Ty<'tcx>,
@@ -36,14 +36,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for Eq<'tcx> {
3636
}
3737
}
3838

39-
BraceStructLiftImpl! {
40-
impl<'a, 'tcx> Lift<'tcx> for Eq<'a> {
41-
type Lifted = Eq<'tcx>;
42-
a,
43-
b,
44-
}
45-
}
46-
4739
impl_stable_hash_for! {
4840
struct Eq<'tcx> { a, b }
4941
}

src/librustc/traits/query/type_op/implied_outlives_bounds.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::traits::query::outlives_bounds::OutlivesBound;
33
use crate::traits::query::Fallible;
44
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
55

6-
#[derive(Clone, Debug, TypeFoldable)]
6+
#[derive(Clone, Debug, TypeFoldable, Lift)]
77
pub struct ImpliedOutlivesBounds<'tcx> {
88
pub ty: Ty<'tcx>,
99
}
@@ -40,13 +40,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
4040
}
4141
}
4242

43-
BraceStructLiftImpl! {
44-
impl<'a, 'tcx> Lift<'tcx> for ImpliedOutlivesBounds<'a> {
45-
type Lifted = ImpliedOutlivesBounds<'tcx>;
46-
ty,
47-
}
48-
}
49-
5043
impl_stable_hash_for! {
5144
struct ImpliedOutlivesBounds<'tcx> { ty }
5245
}

src/librustc/traits/query/type_op/normalize.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::traits::query::Fallible;
44
use crate::ty::fold::TypeFoldable;
55
use crate::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt};
66

7-
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable)]
7+
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable, Lift)]
88
pub struct Normalize<T> {
99
pub value: T,
1010
}
@@ -83,13 +83,6 @@ impl Normalizable<'tcx> for ty::FnSig<'tcx> {
8383
}
8484
}
8585

86-
BraceStructLiftImpl! {
87-
impl<'tcx, T> Lift<'tcx> for Normalize<T> {
88-
type Lifted = Normalize<T::Lifted>;
89-
value,
90-
} where T: Lift<'tcx>,
91-
}
92-
9386
impl_stable_hash_for! {
9487
impl<T> for struct Normalize<T> {
9588
value

src/librustc/traits/query/type_op/outlives.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::traits::query::dropck_outlives::{DropckOutlivesResult, trivial_dropck
33
use crate::traits::query::Fallible;
44
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
55

6-
#[derive(Copy, Clone, Debug, TypeFoldable)]
6+
#[derive(Copy, Clone, Debug, TypeFoldable, Lift)]
77
pub struct DropckOutlives<'tcx> {
88
dropped_ty: Ty<'tcx>,
99
}
@@ -54,13 +54,6 @@ impl super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
5454
}
5555
}
5656

57-
BraceStructLiftImpl! {
58-
impl<'a, 'tcx> Lift<'tcx> for DropckOutlives<'a> {
59-
type Lifted = DropckOutlives<'tcx>;
60-
dropped_ty
61-
}
62-
}
63-
6457
impl_stable_hash_for! {
6558
struct DropckOutlives<'tcx> { dropped_ty }
6659
}

src/librustc/traits/query/type_op/prove_predicate.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::ty::{ParamEnvAnd, Predicate, TyCtxt};
44

5-
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable)]
5+
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable, Lift)]
66
pub struct ProvePredicate<'tcx> {
77
pub predicate: Predicate<'tcx>,
88
}
@@ -45,13 +45,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
4545
}
4646
}
4747

48-
BraceStructLiftImpl! {
49-
impl<'a, 'tcx> Lift<'tcx> for ProvePredicate<'a> {
50-
type Lifted = ProvePredicate<'tcx>;
51-
predicate,
52-
}
53-
}
54-
5548
impl_stable_hash_for! {
5649
struct ProvePredicate<'tcx> { predicate }
5750
}

src/librustc/traits/query/type_op/subtype.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
44

5-
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable)]
5+
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeFoldable, Lift)]
66
pub struct Subtype<'tcx> {
77
pub sub: Ty<'tcx>,
88
pub sup: Ty<'tcx>,
@@ -36,14 +36,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for Subtype<'tcx> {
3636
}
3737
}
3838

39-
BraceStructLiftImpl! {
40-
impl<'a, 'tcx> Lift<'tcx> for Subtype<'a> {
41-
type Lifted = Subtype<'tcx>;
42-
sub,
43-
sup,
44-
}
45-
}
46-
4739
impl_stable_hash_for! {
4840
struct Subtype<'tcx> { sub, sup }
4941
}

src/librustc/ty/context.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -826,20 +826,13 @@ rustc_index::newtype_index! {
826826
pub type CanonicalUserTypeAnnotations<'tcx> =
827827
IndexVec<UserTypeAnnotationIndex, CanonicalUserTypeAnnotation<'tcx>>;
828828

829-
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
829+
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable, Lift)]
830830
pub struct CanonicalUserTypeAnnotation<'tcx> {
831831
pub user_ty: CanonicalUserType<'tcx>,
832832
pub span: Span,
833833
pub inferred_ty: Ty<'tcx>,
834834
}
835835

836-
BraceStructLiftImpl! {
837-
impl<'a, 'tcx> Lift<'tcx> for CanonicalUserTypeAnnotation<'a> {
838-
type Lifted = CanonicalUserTypeAnnotation<'tcx>;
839-
user_ty, span, inferred_ty
840-
}
841-
}
842-
843836
/// Canonicalized user type annotation.
844837
pub type CanonicalUserType<'tcx> = Canonical<'tcx, UserType<'tcx>>;
845838

src/librustc/ty/instance.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use rustc_macros::HashStable;
1212
use std::fmt;
1313
use std::iter;
1414

15-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable, HashStable)]
15+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
16+
#[derive(HashStable, Lift)]
1617
pub struct Instance<'tcx> {
1718
pub def: InstanceDef<'tcx>,
1819
pub substs: SubstsRef<'tcx>,

0 commit comments

Comments
 (0)