|
| 1 | +use crate::rustc_middle::ty::layout::HasTyCtxt; |
1 | 2 | use crate::traits::*; |
2 | 3 | use rustc_hir::def_id::CrateNum; |
3 | 4 | use rustc_index::vec::IndexVec; |
@@ -60,23 +61,28 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { |
60 | 61 | } |
61 | 62 |
|
62 | 63 | pub fn debug_loc(&self, source_info: mir::SourceInfo) -> (Option<Bx::DIScope>, Span) { |
| 64 | + let source_span = self.cx.tcx().reify_span(source_info.span); |
| 65 | + |
63 | 66 | // Bail out if debug info emission is not enabled. |
64 | 67 | match self.debug_context { |
65 | | - None => return (None, source_info.span), |
| 68 | + None => return (None, source_span), |
66 | 69 | Some(_) => {} |
67 | 70 | } |
68 | 71 |
|
69 | 72 | // In order to have a good line stepping behavior in debugger, we overwrite debug |
70 | 73 | // locations of macro expansions with that of the outermost expansion site |
71 | 74 | // (unless the crate is being compiled with `-Z debug-macros`). |
72 | | - if !source_info.span.from_expansion() || self.cx.sess().opts.debugging_opts.debug_macros { |
73 | | - let scope = self.scope_metadata_for_loc(source_info.scope, source_info.span.lo()); |
74 | | - (scope, source_info.span) |
| 75 | + if !source_span.from_expansion() || self.cx.sess().opts.debugging_opts.debug_macros { |
| 76 | + let scope = self.scope_metadata_for_loc(source_info.scope, source_span.lo()); |
| 77 | + (scope, source_span) |
75 | 78 | } else { |
76 | 79 | // Walk up the macro expansion chain until we reach a non-expanded span. |
77 | 80 | // We also stop at the function body level because no line stepping can occur |
78 | 81 | // at the level above that. |
79 | | - let span = rustc_span::hygiene::walk_chain(source_info.span, self.mir.span.ctxt()); |
| 82 | + let span = rustc_span::hygiene::walk_chain( |
| 83 | + source_span, |
| 84 | + self.cx.tcx().reify_span(self.mir.span).ctxt(), |
| 85 | + ); |
80 | 86 | let scope = self.scope_metadata_for_loc(source_info.scope, span.lo()); |
81 | 87 | // Use span of the outermost expansion site, while keeping the original lexical scope. |
82 | 88 | (scope, span) |
@@ -149,7 +155,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { |
149 | 155 | let (scope, span) = if full_debug_info { |
150 | 156 | self.debug_loc(decl.source_info) |
151 | 157 | } else { |
152 | | - (None, decl.source_info.span) |
| 158 | + (None, self.cx.tcx().reify_span(decl.source_info.span)) |
153 | 159 | }; |
154 | 160 | let dbg_var = scope.map(|scope| { |
155 | 161 | // FIXME(eddyb) is this `+ 1` needed at all? |
@@ -312,7 +318,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { |
312 | 318 | let (scope, span) = if full_debug_info { |
313 | 319 | self.debug_loc(var.source_info) |
314 | 320 | } else { |
315 | | - (None, var.source_info.span) |
| 321 | + (None, self.cx.tcx().reify_span(var.source_info.span)) |
316 | 322 | }; |
317 | 323 | let dbg_var = scope.map(|scope| { |
318 | 324 | let place = var.place; |
|
0 commit comments