@@ -533,21 +533,26 @@ pub fn create_argument_metadata(bcx: &Block, arg: &ast::Arg) {
533
533
pub fn set_source_location ( fcx : & FunctionContext ,
534
534
node_id : ast:: NodeId ,
535
535
span : Span ) {
536
- if fn_should_be_ignored ( fcx) {
537
- return ;
538
- }
539
-
540
- let cx = fcx. ccx ;
536
+ match fcx. debug_context {
537
+ DebugInfoDisabled => return ,
538
+ FunctionWithoutDebugInfo => {
539
+ set_debug_location ( fcx. ccx , UnknownLocation ) ;
540
+ return ;
541
+ }
542
+ FunctionDebugContext ( ~ref function_debug_context) => {
543
+ let cx = fcx. ccx ;
541
544
542
- debug ! ( "set_source_location: {}" , cx. sess( ) . codemap( ) . span_to_str( span) ) ;
545
+ debug ! ( "set_source_location: {}" , cx. sess( ) . codemap( ) . span_to_str( span) ) ;
543
546
544
- if fcx . debug_context . get_ref ( cx , span ) . source_locations_enabled . get ( ) {
545
- let loc = span_start ( cx, span) ;
546
- let scope = scope_metadata ( fcx, node_id, span) ;
547
+ if function_debug_context . source_locations_enabled . get ( ) {
548
+ let loc = span_start ( cx, span) ;
549
+ let scope = scope_metadata ( fcx, node_id, span) ;
547
550
548
- set_debug_location ( cx, DebugLocation :: new ( scope, loc. line , loc. col . to_uint ( ) ) ) ;
549
- } else {
550
- set_debug_location ( cx, UnknownLocation ) ;
551
+ set_debug_location ( cx, DebugLocation :: new ( scope, loc. line , loc. col . to_uint ( ) ) ) ;
552
+ } else {
553
+ set_debug_location ( cx, UnknownLocation ) ;
554
+ }
555
+ }
551
556
}
552
557
}
553
558
@@ -590,6 +595,10 @@ pub fn create_function_debug_context(cx: &CrateContext,
590
595
return DebugInfoDisabled ;
591
596
}
592
597
598
+ // Clear the debug location so we don't assign them in the function prelude. Do this here
599
+ // already, in case we do an early exit from this function.
600
+ set_debug_location ( cx, UnknownLocation ) ;
601
+
593
602
if fn_ast_id == -1 {
594
603
return FunctionWithoutDebugInfo ;
595
604
}
@@ -740,9 +749,6 @@ pub fn create_function_debug_context(cx: &CrateContext,
740
749
fn_metadata,
741
750
& mut * fn_debug_context. scope_map . borrow_mut ( ) ) ;
742
751
743
- // Clear the debug location so we don't assign them in the function prelude
744
- set_debug_location ( cx, UnknownLocation ) ;
745
-
746
752
return FunctionDebugContext ( fn_debug_context) ;
747
753
748
754
fn get_function_signature ( cx : & CrateContext ,
0 commit comments