`debug_refcell` points into std source for `LocalKey::with_borrow`
Opened this issue · 0 comments
LHolten commented
I tried this code:
use std::cell::RefCell;
thread_local! {
static FOO: RefCell<()> = RefCell::new(());
}
fn main() {
FOO.with_borrow(|_x| FOO.with_borrow_mut(|_y| {}))
}Run with cargo +nightly run -Zbuild-std -Zbuild-std-features="debug_refcell"
I expect to get an error telling me where the first and second borrow occur in my code.
What actually happens is that I get two locations in the standard library:
thread 'main' (141310) panicked at /home/lucasholten/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:752:38:
RefCell already borrowed; a previous borrow was at /home/lucasholten/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:719:34
It seems to me that LocalKey::with_borrow and LocalKey::with_borrow_mut should have #[track_caller] applied, at least when the debug_refcell feature is used.