Skip to content
  • Lukas Kalbertodt's avatar
    Fix panic message when `RangeFrom` index is out of bounds · ce338046
    Lukas Kalbertodt authored
    Before, the `Range` method was called with `end = slice.len()`.
    Unfortunately, because `Range::index` first checks the order of the
    indices (start has to be smaller than end), an out of bounds index
    leads to `core::slice::slice_index_order_fail` being called. This
    prints the message 'slice index starts at 27 but ends at 10', which is
    worse than 'index 27 out of range for slice of length 10'. This is not
    only useful to normal users reading panic messages, but also for people
    inspecting assembly and being confused by `slice_index_order_fail`
    calls.
    ce338046