Skip to content

Commit 6438b9e

Browse files
Use {Decodable,Encodable}_NoContext in type_ir
1 parent e5a2220 commit 6438b9e

File tree

24 files changed

+281
-105
lines changed

24 files changed

+281
-105
lines changed

compiler/rustc_abi/src/lib.rs

+25-7
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use rustc_data_structures::stable_hasher::StableOrd;
5252
use rustc_hashes::Hash64;
5353
use rustc_index::{Idx, IndexSlice, IndexVec};
5454
#[cfg(feature = "nightly")]
55-
use rustc_macros::{Decodable_Generic, Encodable_Generic, HashStable_Generic};
55+
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_Generic};
5656

5757
mod callconv;
5858
mod layout;
@@ -74,7 +74,10 @@ pub use layout::{LayoutCalculator, LayoutCalculatorError};
7474
pub trait HashStableContext {}
7575

7676
#[derive(Clone, Copy, PartialEq, Eq, Default)]
77-
#[cfg_attr(feature = "nightly", derive(Encodable_Generic, Decodable_Generic, HashStable_Generic))]
77+
#[cfg_attr(
78+
feature = "nightly",
79+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
80+
)]
7881
pub struct ReprFlags(u8);
7982

8083
bitflags! {
@@ -106,7 +109,10 @@ impl std::fmt::Debug for ReprFlags {
106109
}
107110

108111
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
109-
#[cfg_attr(feature = "nightly", derive(Encodable_Generic, Decodable_Generic, HashStable_Generic))]
112+
#[cfg_attr(
113+
feature = "nightly",
114+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
115+
)]
110116
pub enum IntegerType {
111117
/// Pointer-sized integer type, i.e. `isize` and `usize`. The field shows signedness, e.g.
112118
/// `Pointer(true)` means `isize`.
@@ -127,7 +133,10 @@ impl IntegerType {
127133

128134
/// Represents the repr options provided by the user.
129135
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
130-
#[cfg_attr(feature = "nightly", derive(Encodable_Generic, Decodable_Generic, HashStable_Generic))]
136+
#[cfg_attr(
137+
feature = "nightly",
138+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
139+
)]
131140
pub struct ReprOptions {
132141
pub int: Option<IntegerType>,
133142
pub align: Option<Align>,
@@ -487,7 +496,10 @@ impl FromStr for Endian {
487496

488497
/// Size of a type in bytes.
489498
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
490-
#[cfg_attr(feature = "nightly", derive(Encodable_Generic, Decodable_Generic, HashStable_Generic))]
499+
#[cfg_attr(
500+
feature = "nightly",
501+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
502+
)]
491503
pub struct Size {
492504
raw: u64,
493505
}
@@ -713,7 +725,10 @@ impl Step for Size {
713725

714726
/// Alignment of a type in bytes (always a power of two).
715727
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
716-
#[cfg_attr(feature = "nightly", derive(Encodable_Generic, Decodable_Generic, HashStable_Generic))]
728+
#[cfg_attr(
729+
feature = "nightly",
730+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
731+
)]
717732
pub struct Align {
718733
pow2: u8,
719734
}
@@ -872,7 +887,10 @@ impl AbiAndPrefAlign {
872887

873888
/// Integers, also used for enum discriminants.
874889
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
875-
#[cfg_attr(feature = "nightly", derive(Encodable_Generic, Decodable_Generic, HashStable_Generic))]
890+
#[cfg_attr(
891+
feature = "nightly",
892+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
893+
)]
876894
pub enum Integer {
877895
I8,
878896
I16,

compiler/rustc_ast_ir/src/lib.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
// tidy-alphabetical-end
1313

1414
#[cfg(feature = "nightly")]
15-
use rustc_macros::{Decodable, Encodable, HashStable_NoContext};
15+
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
1616

1717
pub mod visit;
1818

1919
/// The movability of a coroutine / closure literal:
2020
/// whether a coroutine contains self-references, causing it to be `!Unpin`.
2121
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
22-
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
22+
#[cfg_attr(
23+
feature = "nightly",
24+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
25+
)]
2326
pub enum Movability {
2427
/// May contain self-references, `!Unpin`.
2528
Static,
@@ -28,7 +31,10 @@ pub enum Movability {
2831
}
2932

3033
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
31-
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
34+
#[cfg_attr(
35+
feature = "nightly",
36+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
37+
)]
3238
pub enum Mutability {
3339
// N.B. Order is deliberate, so that Not < Mut
3440
Not,
@@ -87,7 +93,10 @@ impl Mutability {
8793
}
8894

8995
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
90-
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
96+
#[cfg_attr(
97+
feature = "nightly",
98+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
99+
)]
91100
pub enum Pinnedness {
92101
Not,
93102
Pinned,

compiler/rustc_data_structures/src/sorted_map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fmt::Debug;
44
use std::mem;
55
use std::ops::{Bound, Index, IndexMut, RangeBounds};
66

7-
use rustc_macros::{Decodable_Generic, Encodable_Generic};
7+
use rustc_macros::{Decodable_NoContext, Encodable_NoContext};
88

99
use crate::stable_hasher::{HashStable, StableHasher, StableOrd};
1010

@@ -20,7 +20,7 @@ pub use index_map::SortedIndexMultiMap;
2020
/// stores data in a more compact way. It also supports accessing contiguous
2121
/// ranges of elements as a slice, and slices of already sorted elements can be
2222
/// inserted efficiently.
23-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable_Generic, Decodable_Generic)]
23+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable_NoContext, Decodable_NoContext)]
2424
pub struct SortedMap<K, V> {
2525
data: Vec<(K, V)>,
2626
}

compiler/rustc_data_structures/src/svh.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
88
use std::fmt;
99

10-
use rustc_macros::{Decodable_Generic, Encodable_Generic};
10+
use rustc_macros::{Decodable_NoContext, Encodable_NoContext};
1111

1212
use crate::fingerprint::Fingerprint;
1313
use crate::stable_hasher;
1414

15-
#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable_Generic, Decodable_Generic, Hash)]
15+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable_NoContext, Decodable_NoContext, Hash)]
1616
pub struct Svh {
1717
hash: Fingerprint,
1818
}

compiler/rustc_data_structures/src/unord.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::iter::{Product, Sum};
99
use std::ops::Index;
1010

1111
use rustc_hash::{FxHashMap, FxHashSet};
12-
use rustc_macros::{Decodable_Generic, Encodable_Generic};
12+
use rustc_macros::{Decodable_NoContext, Encodable_NoContext};
1313

1414
use crate::fingerprint::Fingerprint;
1515
use crate::stable_hasher::{HashStable, StableCompare, StableHasher, ToStableHashKey};
@@ -224,7 +224,7 @@ trait UnordCollection {}
224224
///
225225
/// See [MCP 533](https://github.com/rust-lang/compiler-team/issues/533)
226226
/// for more information.
227-
#[derive(Debug, Eq, PartialEq, Clone, Encodable_Generic, Decodable_Generic)]
227+
#[derive(Debug, Eq, PartialEq, Clone, Encodable_NoContext, Decodable_NoContext)]
228228
pub struct UnordSet<V: Eq + Hash> {
229229
inner: FxHashSet<V>,
230230
}
@@ -415,7 +415,7 @@ impl<HCX, V: Hash + Eq + HashStable<HCX>> HashStable<HCX> for UnordSet<V> {
415415
///
416416
/// See [MCP 533](https://github.com/rust-lang/compiler-team/issues/533)
417417
/// for more information.
418-
#[derive(Debug, Eq, PartialEq, Clone, Encodable_Generic, Decodable_Generic)]
418+
#[derive(Debug, Eq, PartialEq, Clone, Encodable_NoContext, Decodable_NoContext)]
419419
pub struct UnordMap<K: Eq + Hash, V> {
420420
inner: FxHashMap<K, V>,
421421
}
@@ -639,7 +639,7 @@ impl<HCX, K: Hash + Eq + HashStable<HCX>, V: HashStable<HCX>> HashStable<HCX> fo
639639
///
640640
/// See [MCP 533](https://github.com/rust-lang/compiler-team/issues/533)
641641
/// for more information.
642-
#[derive(Default, Debug, Eq, PartialEq, Clone, Encodable_Generic, Decodable_Generic)]
642+
#[derive(Default, Debug, Eq, PartialEq, Clone, Encodable_NoContext, Decodable_NoContext)]
643643
pub struct UnordBag<V> {
644644
inner: Vec<V>,
645645
}

compiler/rustc_index/src/bit_set.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{fmt, iter, slice};
77

88
use Chunk::*;
99
#[cfg(feature = "nightly")]
10-
use rustc_macros::{Decodable_Generic, Encodable_Generic};
10+
use rustc_macros::{Decodable_NoContext, Encodable_NoContext};
1111
use smallvec::{SmallVec, smallvec};
1212

1313
use crate::{Idx, IndexVec};
@@ -114,7 +114,7 @@ macro_rules! bit_relations_inherent_impls {
114114
/// to or greater than the domain size. All operations that involve two bitsets
115115
/// will panic if the bitsets have differing domain sizes.
116116
///
117-
#[cfg_attr(feature = "nightly", derive(Decodable_Generic, Encodable_Generic))]
117+
#[cfg_attr(feature = "nightly", derive(Decodable_NoContext, Encodable_NoContext))]
118118
#[derive(Eq, PartialEq, Hash)]
119119
pub struct DenseBitSet<T> {
120120
domain_size: usize,
@@ -1392,7 +1392,7 @@ impl<T: Idx> From<DenseBitSet<T>> for GrowableBitSet<T> {
13921392
///
13931393
/// All operations that involve a row and/or column index will panic if the
13941394
/// index exceeds the relevant bound.
1395-
#[cfg_attr(feature = "nightly", derive(Decodable_Generic, Encodable_Generic))]
1395+
#[cfg_attr(feature = "nightly", derive(Decodable_NoContext, Encodable_NoContext))]
13961396
#[derive(Clone, Eq, PartialEq, Hash)]
13971397
pub struct BitMatrix<R: Idx, C: Idx> {
13981398
num_rows: usize,
@@ -1816,7 +1816,7 @@ impl std::fmt::Debug for FiniteBitSet<u32> {
18161816

18171817
/// A fixed-sized bitset type represented by an integer type. Indices outwith than the range
18181818
/// representable by `T` are considered set.
1819-
#[cfg_attr(feature = "nightly", derive(Decodable_Generic, Encodable_Generic))]
1819+
#[cfg_attr(feature = "nightly", derive(Decodable_NoContext, Encodable_NoContext))]
18201820
#[derive(Copy, Clone, Eq, PartialEq)]
18211821
pub struct FiniteBitSet<T: FiniteBitSetTy>(pub T);
18221822

compiler/rustc_macros/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ decl_derive!(
7474
hash_stable::hash_stable_no_context_derive
7575
);
7676

77-
decl_derive!([Decodable_Generic] => serialize::decodable_generic_derive);
78-
decl_derive!([Encodable_Generic] => serialize::encodable_generic_derive);
77+
decl_derive!([Decodable_NoContext] => serialize::decodable_nocontext_derive);
78+
decl_derive!([Encodable_NoContext] => serialize::encodable_nocontext_derive);
7979
decl_derive!([Decodable] => serialize::decodable_derive);
8080
decl_derive!([Encodable] => serialize::encodable_derive);
8181
decl_derive!([TyDecodable] => serialize::type_decodable_derive);

compiler/rustc_macros/src/serialize.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(super) fn type_decodable_derive(
1515
quote! {}
1616
};
1717

18-
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_type_ir::codec::TyDecoder #bound });
18+
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_middle::ty::codec::TyDecoder #bound });
1919
s.add_bounds(synstructure::AddBounds::Fields);
2020
s.underscore_const(true);
2121

@@ -45,12 +45,12 @@ pub(super) fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro
4545
decodable_body(s, decoder_ty)
4646
}
4747

48-
pub(super) fn decodable_generic_derive(
48+
pub(super) fn decodable_nocontext_derive(
4949
mut s: synstructure::Structure<'_>,
5050
) -> proc_macro2::TokenStream {
5151
let decoder_ty = quote! { __D };
5252
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_serialize::Decoder });
53-
s.add_bounds(synstructure::AddBounds::Generics);
53+
s.add_bounds(synstructure::AddBounds::Fields);
5454
s.underscore_const(true);
5555

5656
decodable_body(s, decoder_ty)
@@ -141,7 +141,7 @@ pub(super) fn type_encodable_derive(
141141
};
142142

143143
let encoder_ty = quote! { __E };
144-
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_type_ir::codec::TyEncoder #bound });
144+
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_middle::ty::codec::TyEncoder #bound });
145145
s.add_bounds(synstructure::AddBounds::Fields);
146146
s.underscore_const(true);
147147

@@ -171,12 +171,12 @@ pub(super) fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro
171171
encodable_body(s, encoder_ty, false)
172172
}
173173

174-
pub(super) fn encodable_generic_derive(
174+
pub(super) fn encodable_nocontext_derive(
175175
mut s: synstructure::Structure<'_>,
176176
) -> proc_macro2::TokenStream {
177177
let encoder_ty = quote! { __E };
178178
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder });
179-
s.add_bounds(synstructure::AddBounds::Generics);
179+
s.add_bounds(synstructure::AddBounds::Fields);
180180
s.underscore_const(true);
181181

182182
encodable_body(s, encoder_ty, false)

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::ops::ControlFlow;
22

33
use derive_where::derive_where;
44
#[cfg(feature = "nightly")]
5-
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
5+
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
66
use rustc_type_ir::data_structures::{HashMap, HashSet, ensure_sufficient_stack};
77
use rustc_type_ir::fast_reject::DeepRejectCtxt;
88
use rustc_type_ir::inherent::*;
@@ -131,7 +131,10 @@ where
131131

132132
#[derive_where(Clone, Debug, Default; I: Interner)]
133133
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
134-
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
134+
#[cfg_attr(
135+
feature = "nightly",
136+
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
137+
)]
135138
struct NestedGoals<I: Interner> {
136139
/// These normalizes-to goals are treated specially during the evaluation
137140
/// loop. In each iteration we take the RHS of the projection, replace it with

compiler/rustc_serialize/tests/opaque.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
use std::fmt::Debug;
44
use std::fs;
55

6-
use rustc_macros::{Decodable_Generic, Encodable_Generic};
6+
use rustc_macros::{Decodable_NoContext, Encodable_NoContext};
77
use rustc_serialize::opaque::{FileEncoder, MemDecoder};
88
use rustc_serialize::{Decodable, Encodable};
99

10-
#[derive(PartialEq, Clone, Debug, Encodable_Generic, Decodable_Generic)]
10+
#[derive(PartialEq, Clone, Debug, Encodable_NoContext, Decodable_NoContext)]
1111
struct Struct {
1212
a: (),
1313
b: u8,
@@ -210,7 +210,7 @@ fn test_struct() {
210210
}]);
211211
}
212212

213-
#[derive(PartialEq, Clone, Debug, Encodable_Generic, Decodable_Generic)]
213+
#[derive(PartialEq, Clone, Debug, Encodable_NoContext, Decodable_NoContext)]
214214
enum Enum {
215215
Variant1,
216216
Variant2(usize, u32),
@@ -259,15 +259,15 @@ fn test_tuples() {
259259

260260
#[test]
261261
fn test_unit_like_struct() {
262-
#[derive(Encodable_Generic, Decodable_Generic, PartialEq, Debug)]
262+
#[derive(Encodable_NoContext, Decodable_NoContext, PartialEq, Debug)]
263263
struct UnitLikeStruct;
264264

265265
check_round_trip(vec![UnitLikeStruct]);
266266
}
267267

268268
#[test]
269269
fn test_box() {
270-
#[derive(Encodable_Generic, Decodable_Generic, PartialEq, Debug)]
270+
#[derive(Encodable_NoContext, Decodable_NoContext, PartialEq, Debug)]
271271
struct A {
272272
foo: Box<[bool]>,
273273
}
@@ -280,12 +280,12 @@ fn test_box() {
280280
fn test_cell() {
281281
use std::cell::{Cell, RefCell};
282282

283-
#[derive(Encodable_Generic, Decodable_Generic, PartialEq, Debug)]
283+
#[derive(Encodable_NoContext, Decodable_NoContext, PartialEq, Debug)]
284284
struct A {
285285
baz: isize,
286286
}
287287

288-
#[derive(Encodable_Generic, Decodable_Generic, PartialEq, Debug)]
288+
#[derive(Encodable_NoContext, Decodable_NoContext, PartialEq, Debug)]
289289
struct B {
290290
foo: Cell<bool>,
291291
bar: RefCell<A>,

compiler/rustc_type_ir/src/binder.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::ops::{ControlFlow, Deref};
55

66
use derive_where::derive_where;
77
#[cfg(feature = "nightly")]
8-
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
8+
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
99
use tracing::instrument;
1010

1111
use crate::data_structures::SsoHashSet;
@@ -342,7 +342,10 @@ impl<I: Interner> TypeVisitor<I> for ValidateBoundVars<I> {
342342
#[derive_where(PartialOrd; I: Interner, T: Ord)]
343343
#[derive_where(Hash; I: Interner, T: Hash)]
344344
#[derive_where(Debug; I: Interner, T: Debug)]
345-
#[cfg_attr(feature = "nightly", derive(TyEncodable, TyDecodable, HashStable_NoContext))]
345+
#[cfg_attr(
346+
feature = "nightly",
347+
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
348+
)]
346349
pub struct EarlyBinder<I: Interner, T> {
347350
value: T,
348351
#[derive_where(skip(Debug))]

0 commit comments

Comments
 (0)