Miscellaneous RefCell cleanups by nealsid · Pull Request #142216 · rust-lang/rust (original) (raw)
Fix the logging when debug_refcell is enabled so the location is output as a string rather than a sequence of bytes
Mind commenting the before and after here?
Location's debug should just print the file, line, and column.
Location only implements Display, not Debug (link). Below is the output if you enable debug_refcell and cause a panic today:
Running `target\debug\refcell-test.exe`
Hello, world! RefCell { value: 5 }
thread 'main' panicked at src\main.rs:11:15:
already borrowed: BorrowMutError { location: Location { file_bytes_with_nul: [115, 114, 99, 92, 109, 97, 105, 110, 46, 114, 115, 0], line: 8, col: 15 } }
stack backtrace:
0: std::panicking::begin_panic_handler
at C:\Users\neals\rust\library\std\src\panicking.rs:697
1: core::panicking::panic_fmt
at C:\Users\neals\rust\library\core\src\panicking.rs:75
2: core::cell::panic_already_borrowed
at C:\Users\neals\rust\library\core\src\cell.rs:791
3: core::cell::RefCell<i32>::borrow_mut<i32>
at C:\Users\neals\rust\library\core\src\cell.rs:1083
4: refcell_test::main
at .\src\main.rs:11
5: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
at C:\Users\neals\rust\library\core\src\ops\function.rs:250
6: core::hint::black_box
at C:\Users\neals\rust\library\core\src\hint.rs:482
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\refcell-test.exe` (exit code: 101)
PS C:\Users\neals\refcell-test>