File tree Expand file tree Collapse file tree
compiler/rustc_data_structures/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,13 +71,18 @@ impl TreeNodeIndex {
7171 /// bitstring.
7272 pub fn branch ( self , i : u64 , n : u64 ) -> TreeNodeIndex {
7373 debug_assert ! ( i < n, "i = {i} should be less than n = {n}" ) ;
74- // `branch_num != 0` per debug assertion above
74+ // `n != 0` per debug assertion above
7575 let bits = ceil_ilog2 ( n) ;
76-
7776 let trailing_zeros = self . 0 . trailing_zeros ( ) ;
77+
78+ // For this panic to happen there has to be a recursive function that isn't a query and
79+ // uses par_join or par_slice recursively.
80+ // Each query starts with a fresh binary tree, so we can expect this to never happen.
81+ // That is unless someone writes 64 nested par_join calls or something equivalent.
7882 let allocated_shift = trailing_zeros. checked_sub ( bits) . expect (
7983 "TreeNodeIndex's free bits have been exhausted, make sure recursion is used carefully" ,
8084 ) ;
85+
8186 // Using wrapping operations for optimization, as edge cases are unreachable:
8287 // - `trailing_zeros < 64` as we are guaranteed at least one bit is set
8388 // - `allocated_shift == trailing_zeros - bits <= trailing_zeros < 64`
You can’t perform that action at this time.
0 commit comments