Make SourceMap
available for early debug-printing of Span
s by Aaron1011 · Pull Request #72618 · rust-lang/rust (original) (raw)
Normally, we debug-print Spans
using the SourceMap
retrieved from
the global TyCtxt
. However, we fall back to printing out the Span
's
raw fields (instead of a file and line number) when we try to print aSpan
before a TyCtxt
is available. This makes debugging early phases
of the compile, such as parsing, much more difficult.
This commit stores a SourceMap
in rustc_span::GlOBALS
as a fallback.
When a TyCtxt
is not available, we try to retrieve one from GLOBALS
- only if this is not available do we fall back to the raw field output.
I'm not sure how to write a test for this - however, this can be
verified locally by setting RUSTC_LOG="rustc_parse=debug"
, and
verifying that the output contains filenames and line numbers.