Skip to content

rustc: hide HirId's fmt::Debug output from -Z span_free_formats. #66850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2302,10 +2302,14 @@ impl<'tcx> Debug for Rvalue<'tcx> {
}
}

AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| {
AggregateKind::Closure(def_id, substs) => ty::tls::with(|tcx| {
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
let name = if tcx.sess.opts.debugging_opts.span_free_formats {
format!("[closure@{:?}]", hir_id)
let substs = tcx.lift(&substs).unwrap();
format!(
"[closure@{}]",
tcx.def_path_str_with_substs(def_id, substs),
)
} else {
format!("[closure@{:?}]", tcx.hir().span(hir_id))
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ pub trait PrettyPrinter<'tcx>:
// FIXME(eddyb) should use `def_span`.
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(did) {
if self.tcx().sess.opts.debugging_opts.span_free_formats {
p!(write("@{:?}", hir_id));
p!(write("@"), print_def_path(did, substs));
} else {
p!(write("@{:?}", self.tcx().hir().span(hir_id)));
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/mir-opt/inline-closure-borrows-arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
// debug _t => _1;
// debug q => _2;
// let mut _0: i32;
// let _3: [closure@HirId { owner: DefIndex(4), local_id: 31 }];
// let mut _4: &[closure@HirId { owner: DefIndex(4), local_id: 31 }];
// let _3: [closure@foo<T>::{{closure}}#0];
// let mut _4: &[closure@foo<T>::{{closure}}#0];
// let mut _5: (&i32, &i32);
// let mut _6: &i32;
// let mut _7: &i32;
Expand All @@ -40,7 +40,7 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
// }
// bb0: {
// ...
// _3 = [closure@HirId { owner: DefIndex(4), local_id: 31 }];
// _3 = [closure@foo::<T>::{{closure}}#0];
// ...
// _4 = &_3;
// ...
Expand Down
6 changes: 3 additions & 3 deletions src/test/mir-opt/inline-closure-captures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ fn foo<T: Copy>(t: T, q: i32) -> (i32, T) {
// debug t => _1;
// debug q => _2;
// let mut _0: (i32, T);
// let _3: [closure@HirId { owner: DefIndex(4), local_id: 15 } q:&i32, t:&T];
// let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T];
// let mut _4: &i32;
// let mut _5: &T;
// let mut _6: &[closure@HirId { owner: DefIndex(4), local_id: 15 } q:&i32, t:&T];
// let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T];
// let mut _7: (i32,);
// let mut _8: i32;
// let mut _11: i32;
Expand All @@ -39,7 +39,7 @@ fn foo<T: Copy>(t: T, q: i32) -> (i32, T) {
// _4 = &_2;
// ...
// _5 = &_1;
// _3 = [closure@HirId { owner: DefIndex(4), local_id: 15 }] { q: move _4, t: move _5 };
// _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 };
// ...
// _6 = &_3;
// ...
Expand Down
6 changes: 3 additions & 3 deletions src/test/mir-opt/inline-closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ fn foo<T: Copy>(_t: T, q: i32) -> i32 {
// debug _t => _1;
// debug q => _2;
// let mut _0: i32;
// let _3: [closure@HirId { owner: DefIndex(4), local_id: 15 }];
// let mut _4: &[closure@HirId { owner: DefIndex(4), local_id: 15 }];
// let _3: [closure@foo<T>::{{closure}}#0];
// let mut _4: &[closure@foo<T>::{{closure}}#0];
// let mut _5: (i32, i32);
// let mut _6: i32;
// let mut _7: i32;
Expand All @@ -33,7 +33,7 @@ fn foo<T: Copy>(_t: T, q: i32) -> i32 {
// }
// bb0: {
// ...
// _3 = [closure@HirId { owner: DefIndex(4), local_id: 15 }];
// _3 = [closure@foo::<T>::{{closure}}#0];
// ...
// _4 = &_3;
// ...
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/retag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn main() {
// }
// END rustc.main.EraseRegions.after.mir
// START rustc.main-{{closure}}.EraseRegions.after.mir
// fn main::{{closure}}#0(_1: &[closure@HirId { owner: DefIndex(13), local_id: 72 }], _2: &i32) -> &i32 {
// fn main::{{closure}}#0(_1: &[closure@main::{{closure}}#0], _2: &i32) -> &i32 {
// ...
// bb0: {
// Retag([fn entry] _1);
Expand Down