Track caller on <usize as ToOffset>::to_offset (#24503)
To get useful logs when reporting bugs involving offsets out of range Release Notes: - N/A
This commit is contained in:
@@ -116,6 +116,7 @@ impl<T: ?Sized> ArenaBox<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn validate(&self) {
|
||||
assert!(
|
||||
self.valid.get(),
|
||||
|
||||
@@ -7320,6 +7320,7 @@ impl ToOffset for Point {
|
||||
}
|
||||
|
||||
impl ToOffset for usize {
|
||||
#[track_caller]
|
||||
fn to_offset<'a>(&self, snapshot: &MultiBufferSnapshot) -> usize {
|
||||
assert!(*self <= snapshot.len(), "offset is out of range");
|
||||
*self
|
||||
|
||||
Reference in New Issue
Block a user