diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 8a7f30ee2c42d..6f6484ae1a596 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -533,21 +533,26 @@ pub fn create_argument_metadata(bcx: &Block, arg: &ast::Arg) { pub fn set_source_location(fcx: &FunctionContext, node_id: ast::NodeId, span: Span) { - if fn_should_be_ignored(fcx) { - return; - } - - let cx = fcx.ccx; + match fcx.debug_context { + DebugInfoDisabled => return, + FunctionWithoutDebugInfo => { + set_debug_location(fcx.ccx, UnknownLocation); + return; + } + FunctionDebugContext(~ref function_debug_context) => { + let cx = fcx.ccx; - debug!("set_source_location: {}", cx.sess().codemap().span_to_str(span)); + debug!("set_source_location: {}", cx.sess().codemap().span_to_str(span)); - if fcx.debug_context.get_ref(cx, span).source_locations_enabled.get() { - let loc = span_start(cx, span); - let scope = scope_metadata(fcx, node_id, span); + if function_debug_context.source_locations_enabled.get() { + let loc = span_start(cx, span); + let scope = scope_metadata(fcx, node_id, span); - set_debug_location(cx, DebugLocation::new(scope, loc.line, loc.col.to_uint())); - } else { - set_debug_location(cx, UnknownLocation); + set_debug_location(cx, DebugLocation::new(scope, loc.line, loc.col.to_uint())); + } else { + set_debug_location(cx, UnknownLocation); + } + } } } @@ -590,6 +595,10 @@ pub fn create_function_debug_context(cx: &CrateContext, return DebugInfoDisabled; } + // Clear the debug location so we don't assign them in the function prelude. Do this here + // already, in case we do an early exit from this function. + set_debug_location(cx, UnknownLocation); + if fn_ast_id == -1 { return FunctionWithoutDebugInfo; } @@ -740,9 +749,6 @@ pub fn create_function_debug_context(cx: &CrateContext, fn_metadata, &mut *fn_debug_context.scope_map.borrow_mut()); - // Clear the debug location so we don't assign them in the function prelude - set_debug_location(cx, UnknownLocation); - return FunctionDebugContext(fn_debug_context); fn get_function_signature(cx: &CrateContext,