add krate_attrs accessor

makes better edges in dep graph
This commit is contained in:
Niko Matsakis 2016-03-16 05:53:45 -04:00
parent ab9b844146
commit cd5cf09635
2 changed files with 11 additions and 5 deletions

View File

@ -19,7 +19,7 @@
use middle::cstore::InlinedItem;
use middle::cstore::InlinedItem as II;
use middle::def_id::DefId;
use middle::def_id::{CRATE_DEF_INDEX, DefId};
use syntax::abi::Abi;
use syntax::ast::{self, Name, NodeId, DUMMY_NODE_ID};
@ -388,6 +388,15 @@ pub fn krate(&self) -> &'ast Crate {
self.forest.krate()
}
/// Get the attributes on the krate. This is preferable to
/// invoking `krate.attrs` because it registers a tighter
/// dep-graph access.
pub fn krate_attrs(&self) -> &'ast [ast::Attribute] {
let crate_root_def_id = DefId::local(CRATE_DEF_INDEX);
self.dep_graph.read(DepNode::Hir(crate_root_def_id));
&self.forest.krate.attrs
}
/// Retrieve the Node corresponding to `id`, panicking if it cannot
/// be found.
pub fn get(&self, id: NodeId) -> Node<'ast> {

View File

@ -90,10 +90,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext)
pub fn needs_gdb_debug_scripts_section(ccx: &CrateContext) -> bool {
let omit_gdb_pretty_printer_section =
attr::contains_name(&ccx.tcx()
.map
.krate()
.attrs,
attr::contains_name(&ccx.tcx().map.krate_attrs(),
"omit_gdb_pretty_printer_section");
!omit_gdb_pretty_printer_section &&