Skip to content

Commit 6ff88f9

Browse files
committed
add krate_attrs accessor
makes better edges in dep graph
1 parent 684c734 commit 6ff88f9

File tree

2 files changed

+11
-5
lines changed
  • src
    • librustc/front/map
    • librustc_trans/trans/debuginfo

2 files changed

+11
-5
lines changed

src/librustc/front/map/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use dep_graph::{DepGraph, DepNode};
1919

2020
use middle::cstore::InlinedItem;
2121
use middle::cstore::InlinedItem as II;
22-
use middle::def_id::DefId;
22+
use middle::def_id::{CRATE_DEF_INDEX, DefId};
2323

2424
use syntax::abi::Abi;
2525
use syntax::ast::{self, Name, NodeId, DUMMY_NODE_ID};
@@ -388,6 +388,15 @@ impl<'ast> Map<'ast> {
388388
self.forest.krate()
389389
}
390390

391+
/// Get the attributes on the krate. This is preferable to
392+
/// invoking `krate.attrs` because it registers a tighter
393+
/// dep-graph access.
394+
pub fn krate_attrs(&self) -> &'ast [ast::Attribute] {
395+
let crate_root_def_id = DefId::local(CRATE_DEF_INDEX);
396+
self.dep_graph.read(DepNode::Hir(crate_root_def_id));
397+
&self.forest.krate.attrs
398+
}
399+
391400
/// Retrieve the Node corresponding to `id`, panicking if it cannot
392401
/// be found.
393402
pub fn get(&self, id: NodeId) -> Node<'ast> {

src/librustc_trans/trans/debuginfo/gdb.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext)
9090

9191
pub fn needs_gdb_debug_scripts_section(ccx: &CrateContext) -> bool {
9292
let omit_gdb_pretty_printer_section =
93-
attr::contains_name(&ccx.tcx()
94-
.map
95-
.krate()
96-
.attrs,
93+
attr::contains_name(&ccx.tcx().map.krate_attrs(),
9794
"omit_gdb_pretty_printer_section");
9895

9996
!omit_gdb_pretty_printer_section &&

0 commit comments

Comments
 (0)