Skip to content

Commit f78b8c0

Browse files
Support #[no_debug] for global variables.
1 parent d554f4c commit f78b8c0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/librustc_trans/debuginfo/metadata.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use llvm::{self, ValueRef};
2323
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor,
2424
DICompositeType, DILexicalBlock, DIFlags};
2525

26+
use rustc::hir::TransFnAttrFlags;
2627
use rustc::hir::def::CtorKind;
2728
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
2829
use rustc::ty::fold::TypeVisitor;
@@ -41,7 +42,7 @@ use std::ffi::CString;
4142
use std::fmt::Write;
4243
use std::ptr;
4344
use std::path::{Path, PathBuf};
44-
use syntax::{ast, attr};
45+
use syntax::ast;
4546
use syntax::symbol::{Interner, InternedString, Symbol};
4647
use syntax_pos::{self, Span, FileName};
4748

@@ -1644,11 +1645,17 @@ pub fn create_global_var_metadata(cx: &CodegenCx,
16441645
}
16451646

16461647
let tcx = cx.tcx;
1647-
let no_mangle = attr::contains_name(&tcx.get_attrs(def_id), "no_mangle");
1648+
let attrs = tcx.trans_fn_attrs(def_id);
1649+
1650+
if attrs.flags.contains(TransFnAttrFlags::NO_DEBUG) {
1651+
return;
1652+
}
1653+
1654+
let no_mangle = attrs.flags.contains(TransFnAttrFlags::NO_MANGLE);
16481655
// We may want to remove the namespace scope if we're in an extern block, see:
16491656
// https://github.com/rust-lang/rust/pull/46457#issuecomment-351750952
16501657
let var_scope = get_namespace_for_item(cx, def_id);
1651-
let span = cx.tcx.def_span(def_id);
1658+
let span = tcx.def_span(def_id);
16521659

16531660
let (file_metadata, line_number) = if span != syntax_pos::DUMMY_SP {
16541661
let loc = span_start(cx, span);

0 commit comments

Comments
 (0)