1
Fork 0

Give spans their parent item during lowering.

We only do this operation when incremental compilation is enabled. This
avoids pessimizing the span handling for non-incremental compilation.
This commit is contained in:
Camille GILLOT 2021-04-18 21:28:23 +02:00
parent 6f782c4e11
commit f84856cbb0
3 changed files with 11 additions and 3 deletions

View file

@ -718,9 +718,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
/// Intercept all spans entering HIR.
/// For now we are not doing anything with the intercepted spans.
/// Mark a span as relative to the current owning item.
fn lower_span(&self, span: Span) -> Span {
span
if self.sess.opts.debugging_opts.incremental_relative_spans {
span.with_parent(Some(self.current_hir_id_owner.0))
} else {
// Do not make spans relative when not using incremental compilation.
span
}
}
fn lower_ident(&self, ident: Ident) -> Ident {