let if_kind = hir::ExprKind::If(new_cond, self.arena.alloc(then), Some(else_expr));
let if_expr = self.expr(span, if_kind, ThinVec::new());
let block = self.block_expr(self.arena.alloc(if_expr));
- hir::ExprKind::Loop(block, opt_label, hir::LoopSource::While, span.with_hi(cond.span.hi()))
+ let span = self.lower_span(span.with_hi(cond.span.hi()));
+ hir::ExprKind::Loop(block, opt_label, hir::LoopSource::While, span)
}
/// Desugar `try { <stmts>; <expr> }` into `{ <stmts>; ::std::ops::Try::from_output(<expr>) }`,
}
/// 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 {
incremental_info: bool = (false, parse_bool, [UNTRACKED],
"print high-level information about incremental reuse (or the lack thereof) \
(default: no)"),
+ incremental_relative_spans: bool = (false, parse_bool, [TRACKED],
+ "hash spans relative to their parent item for incr. comp. (default: no)"),
incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
"verify incr. comp. hashes of green query instances (default: no)"),
inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],