Use LocalDefId for closures more
This commit is contained in:
parent
1202bbaf48
commit
cf2433a74f
29 changed files with 164 additions and 171 deletions
|
@ -1983,53 +1983,45 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||
}
|
||||
|
||||
AggregateKind::Closure(def_id, substs) => ty::tls::with(|tcx| {
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
let name = if tcx.sess.opts.unstable_opts.span_free_formats {
|
||||
let substs = tcx.lift(substs).unwrap();
|
||||
format!(
|
||||
"[closure@{}]",
|
||||
tcx.def_path_str_with_substs(def_id.to_def_id(), substs),
|
||||
)
|
||||
} else {
|
||||
let span = tcx.def_span(def_id);
|
||||
format!(
|
||||
"[closure@{}]",
|
||||
tcx.sess.source_map().span_to_diagnostic_string(span)
|
||||
)
|
||||
};
|
||||
let mut struct_fmt = fmt.debug_struct(&name);
|
||||
|
||||
// FIXME(project-rfc-2229#48): This should be a list of capture names/places
|
||||
if let Some(upvars) = tcx.upvars_mentioned(def_id) {
|
||||
for (&var_id, place) in iter::zip(upvars.keys(), places) {
|
||||
let var_name = tcx.hir().name(var_id);
|
||||
struct_fmt.field(var_name.as_str(), place);
|
||||
}
|
||||
}
|
||||
|
||||
struct_fmt.finish()
|
||||
let name = if tcx.sess.opts.unstable_opts.span_free_formats {
|
||||
let substs = tcx.lift(substs).unwrap();
|
||||
format!(
|
||||
"[closure@{}]",
|
||||
tcx.def_path_str_with_substs(def_id.to_def_id(), substs),
|
||||
)
|
||||
} else {
|
||||
write!(fmt, "[closure]")
|
||||
let span = tcx.def_span(def_id);
|
||||
format!(
|
||||
"[closure@{}]",
|
||||
tcx.sess.source_map().span_to_diagnostic_string(span)
|
||||
)
|
||||
};
|
||||
let mut struct_fmt = fmt.debug_struct(&name);
|
||||
|
||||
// FIXME(project-rfc-2229#48): This should be a list of capture names/places
|
||||
if let Some(upvars) = tcx.upvars_mentioned(def_id) {
|
||||
for (&var_id, place) in iter::zip(upvars.keys(), places) {
|
||||
let var_name = tcx.hir().name(var_id);
|
||||
struct_fmt.field(var_name.as_str(), place);
|
||||
}
|
||||
}
|
||||
|
||||
struct_fmt.finish()
|
||||
}),
|
||||
|
||||
AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| {
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
let name = format!("[generator@{:?}]", tcx.def_span(def_id));
|
||||
let mut struct_fmt = fmt.debug_struct(&name);
|
||||
let name = format!("[generator@{:?}]", tcx.def_span(def_id));
|
||||
let mut struct_fmt = fmt.debug_struct(&name);
|
||||
|
||||
// FIXME(project-rfc-2229#48): This should be a list of capture names/places
|
||||
if let Some(upvars) = tcx.upvars_mentioned(def_id) {
|
||||
for (&var_id, place) in iter::zip(upvars.keys(), places) {
|
||||
let var_name = tcx.hir().name(var_id);
|
||||
struct_fmt.field(var_name.as_str(), place);
|
||||
}
|
||||
// FIXME(project-rfc-2229#48): This should be a list of capture names/places
|
||||
if let Some(upvars) = tcx.upvars_mentioned(def_id) {
|
||||
for (&var_id, place) in iter::zip(upvars.keys(), places) {
|
||||
let var_name = tcx.hir().name(var_id);
|
||||
struct_fmt.field(var_name.as_str(), place);
|
||||
}
|
||||
|
||||
struct_fmt.finish()
|
||||
} else {
|
||||
write!(fmt, "[generator]")
|
||||
}
|
||||
|
||||
struct_fmt.finish()
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue