@@ -46,6 +46,20 @@ const KV_IDX_CENTER: usize = B - 1;
46
46
const EDGE_IDX_LEFT_OF_CENTER : usize = B - 1 ;
47
47
const EDGE_IDX_RIGHT_OF_CENTER : usize = B ;
48
48
49
+ /// Workaround https://github.com/rust-lang/rust/issues/108751
50
+ macro_rules! leaf_node_capacity {
51
+ ( ) => {
52
+ 11
53
+ } ; // instead of: CAPACITY
54
+ }
55
+
56
+ /// Workaround https://github.com/rust-lang/rust/issues/108751
57
+ macro_rules! internal_node_capacity {
58
+ ( ) => {
59
+ 12
60
+ } ; // instead of: 2 * B
61
+ }
62
+
49
63
/// The underlying representation of leaf nodes and part of the representation of internal nodes.
50
64
struct LeafNode < K , V > {
51
65
/// We want to be covariant in `K` and `V`.
@@ -61,8 +75,20 @@ struct LeafNode<K, V> {
61
75
62
76
/// The arrays storing the actual data of the node. Only the first `len` elements of each
63
77
/// array are initialized and valid.
64
- keys : [ MaybeUninit < K > ; CAPACITY ] ,
65
- vals : [ MaybeUninit < V > ; CAPACITY ] ,
78
+ keys : [ MaybeUninit < K > ; leaf_node_capacity ! ( ) ] , // @FIXME leaf_node_capacity!() workaround for https://github.com/rust-lang/rust/issues/108751
79
+ vals : [ MaybeUninit < V > ; leaf_node_capacity ! ( ) ] ,
80
+ }
81
+
82
+ /// @FIXME Remove once we remove leaf_node_capacity!() workaround for https://github.com/rust-lang/rust/issues/108751
83
+ #[ test]
84
+ #[ allow( dead_code) ]
85
+ fn assert_leaf_node_capacity ( ) {
86
+ fn leaf_node ( ) -> LeafNode < char , bool > {
87
+ loop { }
88
+ }
89
+ let node = leaf_node ( ) ;
90
+ let _keys: [ MaybeUninit < char > ; CAPACITY ] = node. keys ;
91
+ let _vals: [ MaybeUninit < bool > ; CAPACITY ] = node. vals ;
66
92
}
67
93
68
94
impl < K , V > LeafNode < K , V > {
@@ -100,7 +126,18 @@ struct InternalNode<K, V> {
100
126
/// The pointers to the children of this node. `len + 1` of these are considered
101
127
/// initialized and valid, except that near the end, while the tree is held
102
128
/// through borrow type `Dying`, some of these pointers are dangling.
103
- edges : [ MaybeUninit < BoxedNode < K , V > > ; 2 * B ] ,
129
+ edges : [ MaybeUninit < BoxedNode < K , V > > ; internal_node_capacity ! ( ) ] , // @FIXME internal_node_capacity!() workaround for https://github.com/rust-lang/rust/issues/108751
130
+ }
131
+
132
+ /// @FIXME Remove once we remove internal_node_capacity!() workaround for https://github.com/rust-lang/rust/issues/108751
133
+ #[ test]
134
+ #[ allow( dead_code) ]
135
+ fn assert_internal_node_capacity ( ) {
136
+ fn internal_node ( ) -> InternalNode < char , bool > {
137
+ loop { }
138
+ }
139
+ let node = internal_node ( ) ;
140
+ let _edges: [ MaybeUninit < BoxedNode < char , bool > > ; 2 * B ] = node. edges ;
104
141
}
105
142
106
143
impl < K , V > InternalNode < K , V > {
0 commit comments