mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Add PRETTY_PRINT_DEBUG_SYMBOLS
This commit is contained in:
parent
173ba925ff
commit
9b68fbe3c9
1 changed files with 27 additions and 15 deletions
|
@ -9,6 +9,14 @@ use std::{fmt, u32};
|
|||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct Symbol(u64);
|
||||
|
||||
// When this is `true` (which it normally should be), Symbol's Debug::fmt implementation
|
||||
// attempts to pretty print debug symbols using interns recorded using
|
||||
// register_debug_idents calls (which should be made in debug mode).
|
||||
// Set it to false if you want to see the raw ModuleId and IdentId ints,
|
||||
// but please set it back to true before checking in the result!
|
||||
#[cfg(debug_assertions)]
|
||||
const PRETTY_PRINT_DEBUG_SYMBOLS: bool = true;
|
||||
|
||||
/// In Debug builds only, Symbol has a name() method that lets
|
||||
/// you look up its name in a global intern table. This table is
|
||||
/// behind a mutex, so it is neither populated nor available in release builds.
|
||||
|
@ -101,6 +109,7 @@ impl Symbol {
|
|||
impl fmt::Debug for Symbol {
|
||||
#[cfg(debug_assertions)]
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if PRETTY_PRINT_DEBUG_SYMBOLS {
|
||||
let module_id = self.module_id();
|
||||
let ident_id = self.ident_id();
|
||||
|
||||
|
@ -122,6 +131,9 @@ impl fmt::Debug for Symbol {
|
|||
fallback_debug_fmt(*self, f)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fallback_debug_fmt(*self, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue