about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-18 00:01:22 +0000
committerbors <bors@rust-lang.org>2014-07-18 00:01:22 +0000
commitf50e4ee559c0e6253e9d46a8e6763e25f7b90d90 (patch)
treecdf3efe3a3533880b6b3e4ea1d82fb76f76419fa
parente288fc6a996562c5e4aca46e22c1da46eb3d086b (diff)
parent731f44de454dff23d655f93705c3db002216fac4 (diff)
downloadrust-f50e4ee559c0e6253e9d46a8e6763e25f7b90d90.tar.gz
rust-f50e4ee559c0e6253e9d46a8e6763e25f7b90d90.zip
auto merge of #15719 : michaelwoerister/rust/global_var_null_span_fix, r=alexcrichton
This should fix issue #15541. It would be good to have an test case for this would also be nice but I haven't had the time to write one. The change is very small though and it doesn't break anything in the existing test suite, so I guess we can add it without test for now.
-rw-r--r--src/librustc/middle/trans/debuginfo.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs
index 49b6f023560..8ecdf907fc4 100644
--- a/src/librustc/middle/trans/debuginfo.rs
+++ b/src/librustc/middle/trans/debuginfo.rs
@@ -799,15 +799,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 =
@@ -822,7 +823,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,