Fix printing of spans with no TyCtxt

This commit is contained in:
John Kåre Alsaker 2018-12-03 19:45:06 +01:00
parent 93294ea456
commit 813b484d1e
2 changed files with 7 additions and 3 deletions

View file

@ -1942,8 +1942,12 @@ pub mod tls {
/// This is a callback from libsyntax as it cannot access the implicit state /// This is a callback from libsyntax as it cannot access the implicit state
/// in librustc otherwise /// in librustc otherwise
fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result {
with(|tcx| { with_opt(|tcx| {
write!(f, "{}", tcx.sess.source_map().span_to_string(span)) if let Some(tcx) = tcx {
write!(f, "{}", tcx.sess.source_map().span_to_string(span))
} else {
syntax_pos::default_span_debug(span, f)
}
}) })
} }

View file

@ -611,7 +611,7 @@ impl serialize::UseSpecializedDecodable for Span {
} }
} }
fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result { pub fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Span") f.debug_struct("Span")
.field("lo", &span.lo()) .field("lo", &span.lo())
.field("hi", &span.hi()) .field("hi", &span.hi())