#diagnostics #borrow #panic #interior-mutability

no-std hv-lease-tracker

no-std compatible tracking of borrow origins, for providing better diagnostics when implementing interior mutability primitives

1 unstable release

0.1.0 Nov 12, 2021

#906 in Concurrency


Used in hv-cell

MIT/Apache

8KB
77 lines

Heavy Lease-Tracker - tracking of borrow origins for diagnostics of runtime borrow failures

LeaseTracker implements a simple system using guards and the Rust core::panic::Location API to track and provide information on the source locations of borrows for when interior mutability primitives you write fail.

no-std compatible; uses alloc for Arc and spinlocks for very short critical sections.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Heavy Lease Tracker - functionality for tracking borrows and providing more helpful errors on runtime borrowing/aliasing violations.

  • LeaseTracker type, for use in smart cells like hv-cell's AtomicRefCell (only on debug with track-leases feature enabled)
  • Lease type, for use in smart references/guard types like hv-cell's AtomicRef/AtomicRefMut and ArcRef/ArcRefMut
  • OpenLease type, representing the origin of a dynamic borrow for diagnostic usage

no_std compatible, but requires alloc for Arcs, Cows, and Strings and uses spinlocks internally to LeaseTracker for synchronizing adding/removing OpenLeases.

hv-lease-tracker is not a super performant crate, and should probably be disabled in your release builds if performance of borrows is critical. It is strictly for diagnostic info.

Dependencies

~195KB