Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
debuginfo: Don't crash when encountering global variable with unknown…
… source span.
  • Loading branch information
michaelwoerister committed Jul 16, 2014
1 parent 6c35d51 commit 731f44d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/librustc/middle/trans/debuginfo.rs
Expand Up @@ -798,15 +798,16 @@ pub fn create_global_var_metadata(cx: &CrateContext,
var_item).as_slice())
};

let filename = span_start(cx, span).file.name.clone();
let file_metadata = file_metadata(cx, filename.as_slice());
let (file_metadata, line_number) = if span != codemap::DUMMY_SP {
let loc = span_start(cx, span);
(file_metadata(cx, loc.file.name.as_slice()), loc.line as c_uint)
} else {
(UNKNOWN_FILE_METADATA, UNKNOWN_LINE_NUMBER)
};

let is_local_to_unit = is_node_local_to_unit(cx, node_id);
let loc = span_start(cx, span);

let variable_type = ty::node_id_to_type(cx.tcx(), node_id);
let type_metadata = type_metadata(cx, variable_type, span);

let namespace_node = namespace_for_item(cx, ast_util::local_def(node_id));
let var_name = token::get_ident(ident).get().to_string();
let linkage_name =
Expand All @@ -821,7 +822,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
var_name,
linkage_name,
file_metadata,
loc.line as c_uint,
line_number,
type_metadata,
is_local_to_unit,
global,
Expand Down

5 comments on commit 731f44d

@bors
Copy link
Contributor

@bors bors commented on 731f44d Jul 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at michaelwoerister@731f44d

@bors
Copy link
Contributor

@bors bors commented on 731f44d Jul 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging michaelwoerister/rust/global_var_null_span_fix = 731f44d into auto

@bors
Copy link
Contributor

@bors bors commented on 731f44d Jul 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

michaelwoerister/rust/global_var_null_span_fix = 731f44d merged ok, testing candidate = f50e4ee

@bors
Copy link
Contributor

@bors bors commented on 731f44d Jul 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = f50e4ee

Please sign in to comment.