@@ -83,10 +83,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
8383 }
8484
8585 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 ) > {
8694 let span = self . adjust_span_for_debugging ( source_info. span ) ;
8795 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) )
9097 }
9198
9299 /// 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> {
148155 let name = kw:: Invalid ;
149156 let decl = & self . mir . local_decls [ local] ;
150157 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 ) ;
154162
155- let arg_ty = self . monomorphize ( & decl. ty ) ;
163+ let arg_ty = self . monomorphize ( & decl. ty ) ;
156164
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+ )
163168 } else {
164169 None
165170 } ;
@@ -313,15 +318,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
313318 let mut per_local = IndexVec :: from_elem ( vec ! [ ] , & self . mir . local_decls ) ;
314319 for var in & self . mir . var_debug_info {
315320 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 )
321322 } else {
322323 None
323324 } ;
324- let dbg_var = dbg_scope_and_span. map ( |( dbg_scope, span) | {
325+ let dbg_var = dbg_scope_and_span. map ( |( dbg_scope, _ , span) | {
325326 let place = var. place ;
326327 let var_ty = self . monomorphized_place_ty ( place. as_ref ( ) ) ;
327328 let var_kind = if self . mir . local_kind ( place. local ) == mir:: LocalKind :: Arg
0 commit comments