Skip to content

Commit 09fd5c7

Browse files
committed
implement custom Debug for MiniCore
When the contents correspond to the default, just output `MiniCore("<default>")` instead of the whole thing. Helps reduce the length of the debug output in the common case.
1 parent 251df51 commit 09fd5c7

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

crates/ide-db/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ pub enum Severity {
385385
Allow,
386386
}
387387

388-
#[derive(Debug, Clone, Copy)]
388+
#[derive(Clone, Copy)]
389389
pub struct MiniCore<'a>(&'a str);
390390

391391
impl<'a> MiniCore<'a> {
@@ -400,6 +400,15 @@ impl<'a> MiniCore<'a> {
400400
}
401401
}
402402

403+
impl std::fmt::Debug for MiniCore<'_> {
404+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
405+
f.debug_tuple("MiniCore")
406+
// don't print the whole contents if they correspond to the default
407+
.field(if self.0 == test_utils::MiniCore::RAW_SOURCE { &"<default>" } else { &self.0 })
408+
.finish()
409+
}
410+
}
411+
403412
impl<'a> Default for MiniCore<'a> {
404413
#[inline]
405414
fn default() -> Self {

0 commit comments

Comments
 (0)