Skip to content

Commit ec21000

Browse files
refactor: lock::observing: extract fn addr from ref. conv. to usize
1 parent 63a24d3 commit ec21000

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

wgpu-core/src/lock/observing.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,16 @@ impl ObservationLog {
369369
self.write_location(new_location);
370370
self.write_action(&Action::Acquisition {
371371
older_rank: older_lock.rank.bit.number(),
372-
older_location: std::ptr::from_ref(older_lock.location) as usize,
372+
older_location: addr(older_lock.location),
373373
newer_rank: new_rank.bit.number(),
374-
newer_location: std::ptr::from_ref(new_location) as usize,
374+
newer_location: addr(new_location),
375375
});
376376
}
377377

378378
fn write_location(&mut self, location: &'static Location<'static>) {
379379
if self.locations_seen.insert(location) {
380380
self.write_action(&Action::Location {
381-
address: std::ptr::from_ref(location) as usize,
381+
address: addr(location),
382382
file: location.file(),
383383
line: location.line(),
384384
column: location.column(),
@@ -473,3 +473,8 @@ impl LockRankSet {
473473
self.bits().trailing_zeros()
474474
}
475475
}
476+
477+
/// Convenience for `std::ptr::from_ref(t) as usize`.
478+
fn addr<T>(t: &T) -> usize {
479+
std::ptr::from_ref(t) as usize
480+
}

0 commit comments

Comments
 (0)