From cd5cf09635c41e3f9b6df79a50c1fb24ee855153 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 16 Mar 2016 05:53:45 -0400 Subject: [PATCH] add krate_attrs accessor makes better edges in dep graph --- src/librustc/front/map/mod.rs | 11 ++++++++++- src/librustc_trans/trans/debuginfo/gdb.rs | 5 +---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/librustc/front/map/mod.rs b/src/librustc/front/map/mod.rs index a1355046f48..6d6f20c70ec 100644 --- a/src/librustc/front/map/mod.rs +++ b/src/librustc/front/map/mod.rs @@ -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> { diff --git a/src/librustc_trans/trans/debuginfo/gdb.rs b/src/librustc_trans/trans/debuginfo/gdb.rs index 4e3fadd0fa9..7740f277586 100644 --- a/src/librustc_trans/trans/debuginfo/gdb.rs +++ b/src/librustc_trans/trans/debuginfo/gdb.rs @@ -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 &&