Skip to content

Commit 955801c

Browse files
Rollup merge of #157241 - aerooneqq:def-path-hash-instrumentation-fix, r=petrochenkov
Trace `?id.local_def_index` instead of `id` in `def_path_hash` Trace `local_def_index` instead of `LocalDefId` in `def_path_hash`, as latter causes errors (previous version of this function accepted `DefIndex`). Fixes #157238. r? @petrochenkov
2 parents f0fe8d5 + 6fac60d commit 955801c

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)