@@ -3,7 +3,7 @@ use crate::rmeta::*;
3
3
use rustc_data_structures:: fingerprint:: Fingerprint ;
4
4
use rustc_hir:: def:: { CtorKind , CtorOf } ;
5
5
use rustc_index:: vec:: Idx ;
6
- use rustc_middle:: ty:: ParameterizedOverTcx ;
6
+ use rustc_middle:: ty:: { ParameterizedOverTcx , UnusedGenericParams } ;
7
7
use rustc_serialize:: opaque:: FileEncoder ;
8
8
use rustc_serialize:: Encoder as _;
9
9
use rustc_span:: hygiene:: MacroKind ;
@@ -50,6 +50,16 @@ impl IsDefault for DefPathHash {
50
50
}
51
51
}
52
52
53
+ impl IsDefault for UnusedGenericParams {
54
+ fn is_default ( & self ) -> bool {
55
+ // UnusedGenericParams encodes the *un*usedness as a bitset.
56
+ // This means that 0 corresponds to all bits used, which is indeed the default.
57
+ let is_default = self . bits ( ) == 0 ;
58
+ debug_assert_eq ! ( is_default, self . all_used( ) ) ;
59
+ is_default
60
+ }
61
+ }
62
+
53
63
/// Helper trait, for encoding to, and decoding from, a fixed number of bytes.
54
64
/// Used mainly for Lazy positions and lengths.
55
65
/// Unchecked invariant: `Self::default()` should encode as `[0; BYTE_LEN]`,
@@ -271,6 +281,21 @@ impl FixedSizeEncoding for bool {
271
281
}
272
282
}
273
283
284
+ impl FixedSizeEncoding for UnusedGenericParams {
285
+ type ByteArray = [ u8 ; 4 ] ;
286
+
287
+ #[ inline]
288
+ fn from_bytes ( b : & [ u8 ; 4 ] ) -> Self {
289
+ let x: u32 = u32:: from_bytes ( b) ;
290
+ UnusedGenericParams :: from_bits ( x)
291
+ }
292
+
293
+ #[ inline]
294
+ fn write_to_bytes ( self , b : & mut [ u8 ; 4 ] ) {
295
+ self . bits ( ) . write_to_bytes ( b) ;
296
+ }
297
+ }
298
+
274
299
// NOTE(eddyb) there could be an impl for `usize`, which would enable a more
275
300
// generic `LazyValue<T>` impl, but in the general case we might not need / want
276
301
// to fit every `usize` in `u32`.
0 commit comments