about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/lib.rs
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2021-04-18 21:28:23 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2021-09-10 20:18:36 +0200
commitf84856cbb0bcba3fae1a74a7e913e1a42d7144f0 (patch)
tree4b8dacedfd9944ab86052327b2a4345ccad20402 /compiler/rustc_ast_lowering/src/lib.rs
parent6f782c4e114c2913d5f3e8034664852e7b36452a (diff)
downloadrust-f84856cbb0bcba3fae1a74a7e913e1a42d7144f0.tar.gz
rust-f84856cbb0bcba3fae1a74a7e913e1a42d7144f0.zip
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.
Diffstat (limited to 'compiler/rustc_ast_lowering/src/lib.rs')
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 9edc30ceb19..8d731d7a578 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -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 {