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:
João Marcos 2025-02-08 12:29:29 -03:00 committed by GitHub
parent b1055878c7
commit 0294b19694
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View file

@ -116,6 +116,7 @@ impl<T: ?Sized> ArenaBox<T> {
}
}
#[track_caller]
fn validate(&self) {
assert!(
self.valid.get(),

View file

@ -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