Rollup merge of #46120 - arielb1:def-debug, r=michaelwoerister
clean the Debug impl for CrateNum and DefId
Just a tiny quality-of-life improvement because I got tired of noisy debug logs.
```
before: DefId { krate: CrateNum(11), index: DefIndex(0:6) => foo[8787]::Mapper[0]::OtherType[0] } }
after: {crate11:0:6 ~ foo[8787]::Mapper[0]::OtherType[0]})
```
r? @michaelwoerister
This commit is contained in:
commit
e77f3e4781
4 changed files with 17 additions and 15 deletions
|
|
@ -17,8 +17,8 @@ use std::u32;
|
|||
|
||||
newtype_index!(CrateNum
|
||||
{
|
||||
derive[Debug]
|
||||
ENCODABLE = custom
|
||||
DEBUG_FORMAT = "crate{}",
|
||||
|
||||
/// Item definitions in the currently-compiled crate would have the CrateNum
|
||||
/// LOCAL_CRATE in their DefId.
|
||||
|
|
@ -172,17 +172,19 @@ pub struct DefId {
|
|||
|
||||
impl fmt::Debug for DefId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "DefId {{ krate: {:?}, index: {:?}",
|
||||
self.krate, self.index)?;
|
||||
write!(f, "DefId({:?}/{}:{}",
|
||||
self.krate.index(),
|
||||
self.index.address_space().index(),
|
||||
self.index.as_array_index())?;
|
||||
|
||||
ty::tls::with_opt(|opt_tcx| {
|
||||
if let Some(tcx) = opt_tcx {
|
||||
write!(f, " => {}", tcx.def_path_debug_str(*self))?;
|
||||
write!(f, " ~ {}", tcx.def_path_debug_str(*self))?;
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
write!(f, " }}")
|
||||
write!(f, ")")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue