Skip to content

Commit 77aed00

Browse files
authored
Rollup merge of #66850 - eddyb:span-free-formats, r=oli-obk
rustc: hide HirId's fmt::Debug output from -Z span_free_formats. This replaces the only occurrences of `HirId {...}` from tests with paths, i.e.: ```rust [closure@HirId { owner: DefIndex(4), local_id: 15 } q:&i32, t:&T] ``` becomes, after this PR: ```rust [closure@foo<T>::{{closure}}#0 q:&i32, t:&T] ``` r? @oli-obk cc @michaelwoerister
2 parents ac8a402 + 7171060 commit 77aed00

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

src/librustc/mir/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -2313,10 +2313,14 @@ impl<'tcx> Debug for Rvalue<'tcx> {
23132313
}
23142314
}
23152315

2316-
AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| {
2316+
AggregateKind::Closure(def_id, substs) => ty::tls::with(|tcx| {
23172317
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
23182318
let name = if tcx.sess.opts.debugging_opts.span_free_formats {
2319-
format!("[closure@{:?}]", hir_id)
2319+
let substs = tcx.lift(&substs).unwrap();
2320+
format!(
2321+
"[closure@{}]",
2322+
tcx.def_path_str_with_substs(def_id, substs),
2323+
)
23202324
} else {
23212325
format!("[closure@{:?}]", tcx.hir().span(hir_id))
23222326
};

src/librustc/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ pub trait PrettyPrinter<'tcx>:
682682
// FIXME(eddyb) should use `def_span`.
683683
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(did) {
684684
if self.tcx().sess.opts.debugging_opts.span_free_formats {
685-
p!(write("@{:?}", hir_id));
685+
p!(write("@"), print_def_path(did, substs));
686686
} else {
687687
p!(write("@{:?}", self.tcx().hir().span(hir_id)));
688688
}

src/test/mir-opt/inline-closure-borrows-arg.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
2121
// debug _t => _1;
2222
// debug q => _2;
2323
// let mut _0: i32;
24-
// let _3: [closure@HirId { owner: DefIndex(4), local_id: 31 }];
25-
// let mut _4: &[closure@HirId { owner: DefIndex(4), local_id: 31 }];
24+
// let _3: [closure@foo<T>::{{closure}}#0];
25+
// let mut _4: &[closure@foo<T>::{{closure}}#0];
2626
// let mut _5: (&i32, &i32);
2727
// let mut _6: &i32;
2828
// let mut _7: &i32;
@@ -40,7 +40,7 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
4040
// }
4141
// bb0: {
4242
// ...
43-
// _3 = [closure@HirId { owner: DefIndex(4), local_id: 31 }];
43+
// _3 = [closure@foo::<T>::{{closure}}#0];
4444
// ...
4545
// _4 = &_3;
4646
// ...

src/test/mir-opt/inline-closure-captures.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ fn foo<T: Copy>(t: T, q: i32) -> (i32, T) {
1717
// debug t => _1;
1818
// debug q => _2;
1919
// let mut _0: (i32, T);
20-
// let _3: [closure@HirId { owner: DefIndex(4), local_id: 15 } q:&i32, t:&T];
20+
// let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T];
2121
// let mut _4: &i32;
2222
// let mut _5: &T;
23-
// let mut _6: &[closure@HirId { owner: DefIndex(4), local_id: 15 } q:&i32, t:&T];
23+
// let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T];
2424
// let mut _7: (i32,);
2525
// let mut _8: i32;
2626
// let mut _11: i32;
@@ -39,7 +39,7 @@ fn foo<T: Copy>(t: T, q: i32) -> (i32, T) {
3939
// _4 = &_2;
4040
// ...
4141
// _5 = &_1;
42-
// _3 = [closure@HirId { owner: DefIndex(4), local_id: 15 }] { q: move _4, t: move _5 };
42+
// _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 };
4343
// ...
4444
// _6 = &_3;
4545
// ...

src/test/mir-opt/inline-closure.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ fn foo<T: Copy>(_t: T, q: i32) -> i32 {
1717
// debug _t => _1;
1818
// debug q => _2;
1919
// let mut _0: i32;
20-
// let _3: [closure@HirId { owner: DefIndex(4), local_id: 15 }];
21-
// let mut _4: &[closure@HirId { owner: DefIndex(4), local_id: 15 }];
20+
// let _3: [closure@foo<T>::{{closure}}#0];
21+
// let mut _4: &[closure@foo<T>::{{closure}}#0];
2222
// let mut _5: (i32, i32);
2323
// let mut _6: i32;
2424
// let mut _7: i32;
@@ -33,7 +33,7 @@ fn foo<T: Copy>(_t: T, q: i32) -> i32 {
3333
// }
3434
// bb0: {
3535
// ...
36-
// _3 = [closure@HirId { owner: DefIndex(4), local_id: 15 }];
36+
// _3 = [closure@foo::<T>::{{closure}}#0];
3737
// ...
3838
// _4 = &_3;
3939
// ...

src/test/mir-opt/retag.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn main() {
100100
// }
101101
// END rustc.main.EraseRegions.after.mir
102102
// START rustc.main-{{closure}}.EraseRegions.after.mir
103-
// fn main::{{closure}}#0(_1: &[closure@HirId { owner: DefIndex(13), local_id: 72 }], _2: &i32) -> &i32 {
103+
// fn main::{{closure}}#0(_1: &[closure@main::{{closure}}#0], _2: &i32) -> &i32 {
104104
// ...
105105
// bb0: {
106106
// Retag([fn entry] _1);

0 commit comments

Comments
 (0)