@@ -226,12 +226,12 @@ impl SerializedDepGraph {
226
226
227
227
// If the length of this node's edge list is small, the length is stored in the header.
228
228
// If it is not, we fall back to another decoder call.
229
- let num_edges = node_header. len ( ) . unwrap_or_else ( || d. read_usize ( ) ) ;
229
+ let num_edges = node_header. len ( ) . unwrap_or_else ( || d. read_u32 ( ) ) ;
230
230
231
231
// The edges index list uses the same varint strategy as rmeta tables; we select the
232
232
// number of byte elements per-array not per-element. This lets us read the whole edge
233
233
// list for a node with one decoder call and also use the on-disk format in memory.
234
- let edges_len_bytes = node_header. bytes_per_index ( ) * num_edges;
234
+ let edges_len_bytes = node_header. bytes_per_index ( ) * ( num_edges as usize ) ;
235
235
// The in-memory structure for the edges list stores the byte width of the edges on
236
236
// this node with the offset into the global edge data array.
237
237
let edges_header = node_header. edges_header ( & edge_list_data) ;
@@ -296,7 +296,7 @@ struct SerializedNodeHeader<D> {
296
296
// The fields of a `SerializedNodeHeader`, this struct is an implementation detail and exists only
297
297
// to make the implementation of `SerializedNodeHeader` simpler.
298
298
struct Unpacked {
299
- len : Option < usize > ,
299
+ len : Option < u32 > ,
300
300
bytes_per_index : usize ,
301
301
kind : DepKind ,
302
302
hash : PackedFingerprint ,
@@ -366,7 +366,7 @@ impl<D: Deps> SerializedNodeHeader<D> {
366
366
367
367
let kind = head & mask ( Self :: KIND_BITS ) as u16 ;
368
368
let bytes_per_index = ( head >> Self :: KIND_BITS ) & mask ( Self :: WIDTH_BITS ) as u16 ;
369
- let len = ( head as usize ) >> ( Self :: WIDTH_BITS + Self :: KIND_BITS ) ;
369
+ let len = ( head as u32 ) >> ( Self :: WIDTH_BITS + Self :: KIND_BITS ) ;
370
370
371
371
Unpacked {
372
372
len : len. checked_sub ( 1 ) ,
@@ -378,7 +378,7 @@ impl<D: Deps> SerializedNodeHeader<D> {
378
378
}
379
379
380
380
#[ inline]
381
- fn len ( & self ) -> Option < usize > {
381
+ fn len ( & self ) -> Option < u32 > {
382
382
self . unpack ( ) . len
383
383
}
384
384
@@ -421,7 +421,8 @@ impl NodeInfo {
421
421
e. write_array ( header. bytes ) ;
422
422
423
423
if header. len ( ) . is_none ( ) {
424
- e. emit_usize ( edges. len ( ) ) ;
424
+ // The edges are all unique and the number of unique indices is less than u32::MAX.
425
+ e. emit_u32 ( edges. len ( ) . try_into ( ) . unwrap ( ) ) ;
425
426
}
426
427
427
428
let bytes_per_index = header. bytes_per_index ( ) ;
@@ -456,7 +457,8 @@ impl NodeInfo {
456
457
e. write_array ( header. bytes ) ;
457
458
458
459
if header. len ( ) . is_none ( ) {
459
- e. emit_usize ( edge_count) ;
460
+ // The edges are all unique and the number of unique indices is less than u32::MAX.
461
+ e. emit_u32 ( edge_count. try_into ( ) . unwrap ( ) ) ;
460
462
}
461
463
462
464
let bytes_per_index = header. bytes_per_index ( ) ;
0 commit comments