about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-12-12 17:31:48 +0000
committerbors <bors@rust-lang.org>2016-12-12 17:31:48 +0000
commit6483bdd860fd89fc68846d4cc94c7ae3307a84c1 (patch)
tree89e1915e993bafafd75c02fad6203a98a8f3635e
parentb4b1e5ece21fb497877350c3d6defa143c88076c (diff)
parent271fb2292449848ba0259d52314d821f028cf374 (diff)
Auto merge of #38243 - michaelwoerister:fix-debuginfo-namespace-edge, r=nikomatsakis
incr.comp.: Avoid creating an edge to DepNode::Krate when generating debuginfo namespaces.

r? @nikomatsakis

Fixes #38222
-rw-r--r--src/librustc/hir/map/mod.rs7
-rw-r--r--src/librustc_incremental/calculate_svh/mod.rs5
-rw-r--r--src/librustc_incremental/calculate_svh/svh_visitor.rs22
-rw-r--r--src/test/incremental/issue-38222.rs40
4 files changed, 68 insertions, 6 deletions
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index 6ce6f6896df..117edcf14a1 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -310,8 +310,9 @@ impl<'ast> Map<'ast> {
                         id = p;
                     }
 
-                    RootCrate =>
-                        return DepNode::Krate,
+                    RootCrate => {
+                        return DepNode::Hir(DefId::local(CRATE_DEF_INDEX));
+                    }
 
                     RootInlinedParent(_) =>
                         bug!("node {} has inlined ancestor but is not inlined", id0),
@@ -782,7 +783,7 @@ impl<'ast> Map<'ast> {
             Some(EntryVisibility(_, &Visibility::Restricted { ref path, .. })) => path.span,
             Some(EntryVisibility(_, v)) => bug!("unexpected Visibility {:?}", v),
 
-            Some(RootCrate) => self.krate().span,
+            Some(RootCrate) => self.forest.krate.span,
             Some(RootInlinedParent(parent)) => parent.body.span,
             Some(NotPresent) | None => {
                 bug!("hir::map::Map::span: id not in map: {:?}", id)
diff --git a/src/librustc_incremental/calculate_svh/mod.rs b/src/librustc_incremental/calculate_svh/mod.rs
index 4595a940f10..df65c4d2794 100644
--- a/src/librustc_incremental/calculate_svh/mod.rs
+++ b/src/librustc_incremental/calculate_svh/mod.rs
@@ -112,8 +112,9 @@ pub fn compute_incremental_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
         hash_spans: hash_spans,
     };
     record_time(&tcx.sess.perf_stats.incr_comp_hashes_time, || {
-        visitor.calculate_def_id(DefId::local(CRATE_DEF_INDEX),
-                                 |v| visit::walk_crate(v, krate));
+        visitor.calculate_def_id(DefId::local(CRATE_DEF_INDEX), |v| {
+            v.hash_crate_root_module(krate);
+        });
         krate.visit_all_item_likes(&mut visitor.as_deep_visitor());
 
         for macro_def in krate.exported_macros.iter() {
diff --git a/src/librustc_incremental/calculate_svh/svh_visitor.rs b/src/librustc_incremental/calculate_svh/svh_visitor.rs
index 681ad2efa0c..de52b70f1ec 100644
--- a/src/librustc_incremental/calculate_svh/svh_visitor.rs
+++ b/src/librustc_incremental/calculate_svh/svh_visitor.rs
@@ -619,9 +619,10 @@ impl<'a, 'hash, 'tcx> visit::Visitor<'tcx> for StrictVersionHashVisitor<'a, 'has
         visit::walk_item(self, i)
     }
 
-    fn visit_mod(&mut self, m: &'tcx Mod, _s: Span, n: NodeId) {
+    fn visit_mod(&mut self, m: &'tcx Mod, span: Span, n: NodeId) {
         debug!("visit_mod: st={:?}", self.st);
         SawMod.hash(self.st);
+        hash_span!(self, span);
         visit::walk_mod(self, m, n)
     }
 
@@ -1085,4 +1086,23 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
             token::Token::Shebang(val) => val.as_str().hash(self.st),
         }
     }
+
+    pub fn hash_crate_root_module(&mut self, krate: &'tcx Crate) {
+        let hir::Crate {
+            ref module,
+            ref attrs,
+            span,
+
+            // These fields are handled separately:
+            exported_macros: _,
+            items: _,
+            impl_items: _,
+            exprs: _,
+        } = *krate;
+
+        visit::Visitor::visit_mod(self, module, span, ast::CRATE_NODE_ID);
+        // Crate attributes are not copied over to the root `Mod`, so hash them
+        // explicitly here.
+        hash_attrs!(self, attrs);
+    }
 }
diff --git a/src/test/incremental/issue-38222.rs b/src/test/incremental/issue-38222.rs
new file mode 100644
index 00000000000..d14b1cfd6c9
--- /dev/null
+++ b/src/test/incremental/issue-38222.rs
@@ -0,0 +1,40 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that debuginfo does not introduce a dependency edge to the Krate
+// dep-node.
+
+// revisions:rpass1 rpass2
+
+#![feature(rustc_attrs)]
+
+
+#![rustc_partition_translated(module="issue_38222-mod1", cfg="rpass2")]
+
+// If trans had added a dependency edge to the Krate dep-node, nothing would
+// be re-used, so checking that this module was re-used is sufficient.
+#![rustc_partition_reused(module="issue_38222", cfg="rpass2")]
+
+//[rpass1] compile-flags: -C debuginfo=1
+//[rpass2] compile-flags: -C debuginfo=1
+
+pub fn main() {
+    mod1::some_fn();
+}
+
+mod mod1 {
+    pub fn some_fn() {
+        let _ = 1;
+    }
+
+    #[cfg(rpass2)]
+    fn _some_other_fn() {
+    }
+}