Skip to content

Commit

Permalink
Fix printing of spans with no TyCtxt
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Dec 6, 2018
1 parent 93294ea commit 813b484
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/librustc/ty/context.rs
Expand Up @@ -1942,8 +1942,12 @@ pub mod tls {
/// This is a callback from libsyntax as it cannot access the implicit state
/// in librustc otherwise
fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result {
with(|tcx| {
write!(f, "{}", tcx.sess.source_map().span_to_string(span))
with_opt(|tcx| {
if let Some(tcx) = tcx {
write!(f, "{}", tcx.sess.source_map().span_to_string(span))
} else {
syntax_pos::default_span_debug(span, f)
}
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_pos/lib.rs
Expand Up @@ -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")
.field("lo", &span.lo())
.field("hi", &span.hi())
Expand Down

0 comments on commit 813b484

Please sign in to comment.