Split span_to_string into span_to_diagnostic/embeddable_string
This commit is contained in:
parent
0ac9ca4f88
commit
37dbe868c9
13 changed files with 60 additions and 24 deletions
|
@ -262,7 +262,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
|||
span,
|
||||
"inconsistent DepNode at `{:?}` for `{}`: \
|
||||
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?})",
|
||||
self.source_map.span_to_string(span),
|
||||
self.source_map.span_to_diagnostic_string(span),
|
||||
node_str,
|
||||
self.definitions
|
||||
.def_path(self.current_dep_node_owner)
|
||||
|
|
|
@ -2365,7 +2365,10 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||
)
|
||||
} else {
|
||||
let span = tcx.hir().span(hir_id);
|
||||
format!("[closure@{}]", tcx.sess.source_map().span_to_string(span))
|
||||
format!(
|
||||
"[closure@{}]",
|
||||
tcx.sess.source_map().span_to_diagnostic_string(span)
|
||||
)
|
||||
};
|
||||
let mut struct_fmt = fmt.debug_struct(&name);
|
||||
|
||||
|
|
|
@ -667,7 +667,12 @@ pub trait PrettyPrinter<'tcx>:
|
|||
if let Some(did) = did.as_local() {
|
||||
let hir_id = self.tcx().hir().local_def_id_to_hir_id(did);
|
||||
let span = self.tcx().hir().span(hir_id);
|
||||
p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
|
||||
p!(write(
|
||||
"@{}",
|
||||
// This may end up in stderr diagnostics but it may also be emitted
|
||||
// into MIR. Hence we use the remapped path if available
|
||||
self.tcx().sess.source_map().span_to_embeddable_string(span)
|
||||
));
|
||||
} else {
|
||||
p!(write("@"), print_def_path(did, substs));
|
||||
}
|
||||
|
@ -702,7 +707,12 @@ pub trait PrettyPrinter<'tcx>:
|
|||
p!("@", print_def_path(did.to_def_id(), substs));
|
||||
} else {
|
||||
let span = self.tcx().hir().span(hir_id);
|
||||
p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
|
||||
p!(write(
|
||||
"@{}",
|
||||
// This may end up in stderr diagnostics but it may also be emitted
|
||||
// into MIR. Hence we use the remapped path if available
|
||||
self.tcx().sess.source_map().span_to_embeddable_string(span)
|
||||
));
|
||||
}
|
||||
} else {
|
||||
p!(write("@"), print_def_path(did, substs));
|
||||
|
@ -1407,7 +1417,13 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
|
|||
if !self.empty_path {
|
||||
write!(self, "::")?;
|
||||
}
|
||||
write!(self, "<impl at {}>", self.tcx.sess.source_map().span_to_string(span))?;
|
||||
write!(
|
||||
self,
|
||||
"<impl at {}>",
|
||||
// This may end up in stderr diagnostics but it may also be emitted
|
||||
// into MIR. Hence we use the remapped path if available
|
||||
self.tcx.sess.source_map().span_to_embeddable_string(span)
|
||||
)?;
|
||||
self.empty_path = false;
|
||||
|
||||
return Ok(self);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue