@@ -83,10 +83,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
83
83
}
84
84
85
85
fn dbg_loc ( & self , source_info : mir:: SourceInfo ) -> Option < Bx :: DILocation > {
86
+ let ( dbg_scope, inlined_at, span) = self . adjusted_span_and_dbg_scope ( source_info) ?;
87
+ Some ( self . cx . dbg_loc ( dbg_scope, inlined_at, span) )
88
+ }
89
+
90
+ fn adjusted_span_and_dbg_scope (
91
+ & self ,
92
+ source_info : mir:: SourceInfo ,
93
+ ) -> Option < ( Bx :: DIScope , Option < Bx :: DILocation > , Span ) > {
86
94
let span = self . adjust_span_for_debugging ( source_info. span ) ;
87
95
let scope = & self . debug_context . as_ref ( ) ?. scopes [ source_info. scope ] ;
88
- let dbg_scope = scope. adjust_dbg_scope_for_span ( self . cx , span) ;
89
- Some ( self . cx . dbg_loc ( dbg_scope, scope. inlined_at , span) )
96
+ Some ( ( scope. adjust_dbg_scope_for_span ( self . cx , span) , scope. inlined_at , span) )
90
97
}
91
98
92
99
/// In order to have a good line stepping behavior in debugger, we overwrite debug
@@ -148,18 +155,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
148
155
let name = kw:: Invalid ;
149
156
let decl = & self . mir . local_decls [ local] ;
150
157
let dbg_var = if full_debug_info {
151
- self . debug_context . as_ref ( ) . map ( |debug_context| {
152
- // FIXME(eddyb) is this `+ 1` needed at all?
153
- let kind = VariableKind :: ArgumentVariable ( arg_index + 1 ) ;
158
+ self . adjusted_span_and_dbg_scope ( decl. source_info ) . map (
159
+ |( dbg_scope, _, span) | {
160
+ // FIXME(eddyb) is this `+ 1` needed at all?
161
+ let kind = VariableKind :: ArgumentVariable ( arg_index + 1 ) ;
154
162
155
- let arg_ty = self . monomorphize ( & decl. ty ) ;
163
+ let arg_ty = self . monomorphize ( & decl. ty ) ;
156
164
157
- let span = self . adjust_span_for_debugging ( decl. source_info . span ) ;
158
- let scope = & debug_context. scopes [ decl. source_info . scope ] ;
159
- let dbg_scope = scope. adjust_dbg_scope_for_span ( self . cx , span) ;
160
-
161
- self . cx . create_dbg_var ( name, arg_ty, dbg_scope, kind, span)
162
- } )
165
+ self . cx . create_dbg_var ( name, arg_ty, dbg_scope, kind, span)
166
+ } ,
167
+ )
163
168
} else {
164
169
None
165
170
} ;
@@ -313,15 +318,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
313
318
let mut per_local = IndexVec :: from_elem ( vec ! [ ] , & self . mir . local_decls ) ;
314
319
for var in & self . mir . var_debug_info {
315
320
let dbg_scope_and_span = if full_debug_info {
316
- self . debug_context . as_ref ( ) . map ( |debug_context| {
317
- let span = self . adjust_span_for_debugging ( var. source_info . span ) ;
318
- let scope = & debug_context. scopes [ var. source_info . scope ] ;
319
- ( scope. adjust_dbg_scope_for_span ( self . cx , span) , span)
320
- } )
321
+ self . adjusted_span_and_dbg_scope ( var. source_info )
321
322
} else {
322
323
None
323
324
} ;
324
- let dbg_var = dbg_scope_and_span. map ( |( dbg_scope, span) | {
325
+ let dbg_var = dbg_scope_and_span. map ( |( dbg_scope, _ , span) | {
325
326
let place = var. place ;
326
327
let var_ty = self . monomorphized_place_ty ( place. as_ref ( ) ) ;
327
328
let var_kind = if self . mir . local_kind ( place. local ) == mir:: LocalKind :: Arg
0 commit comments