Skip to content

Commit 6fac60d

Browse files
committed
Trace ?id.local_def_index instead of id in def_path_hash
1 parent bef8e62 commit 6fac60d

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

compiler/rustc_hir/src/definitions.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ impl Definitions {
252252
self.def_id_to_key[id]
253253
}
254254

255-
#[instrument(level = "trace", skip(self), ret)]
255+
// Log debug version of `local_def_index` (just a number), as tracing of this function
256+
// is called too early and cause errors if `LocalDefId` is logged (#157238).
257+
#[instrument(level = "trace", skip(self, id), fields(def_index=?id.local_def_index), ret)]
256258
#[inline(always)]
257259
pub fn def_path_hash(&self, id: LocalDefId) -> DefPathHash {
258260
DefPathHash::new(self.stable_crate_id, self.def_path_hashes[id])
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ run-pass
2+
//
3+
// Ensure that `trace` level instrumentation in `def_path_hash` works,
4+
// see #157238.
5+
//
6+
//@ dont-check-compiler-stdout
7+
//@ dont-check-compiler-stderr
8+
//@ rustc-env:RUSTC_LOG=trace
9+
fn main() {}

0 commit comments

Comments
 (0)