about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/dep_graph/dep_node.rs15
-rw-r--r--src/librustc/hir/map/collector.rs9
-rw-r--r--src/librustc/hir/map/hir_id_validator.rs2
-rw-r--r--src/librustc/hir/map/mod.rs9
-rw-r--r--src/librustc/hir/mod.rs8
-rw-r--r--src/librustc/query/mod.rs6
-rw-r--r--src/librustc/ty/query/plumbing.rs1
-rw-r--r--src/librustc_driver/pretty.rs6
-rw-r--r--src/librustc_resolve/lifetimes.rs2
-rw-r--r--src/librustdoc/test.rs2
-rw-r--r--src/test/incremental/crate_hash_reorder.rs8
-rw-r--r--src/test/incremental/issue-38222.rs12
-rw-r--r--src/test/incremental/krate-inherent.rs8
-rw-r--r--src/test/incremental/krate-inlined.rs4
-rw-r--r--src/test/ui/dep-graph/dep-graph-variance-alias.rs9
-rw-r--r--src/test/ui/dep-graph/dep-graph-variance-alias.stderr2
16 files changed, 42 insertions, 61 deletions
diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs
index 9df8e28254c..29b94986a5f 100644
--- a/src/librustc/dep_graph/dep_node.rs
+++ b/src/librustc/dep_graph/dep_node.rs
@@ -35,7 +35,7 @@
 //! "infer" some properties for each kind of `DepNode`:
 //!
 //! * Whether a `DepNode` of a given kind has any parameters at all. Some
-//!   `DepNode`s, like `Krate`, represent global concepts with only one value.
+//!   `DepNode`s, like `AllLocalTraitImpls`, represent global concepts with only one value.
 //! * Whether it is possible, in principle, to reconstruct a query key from a
 //!   given `DepNode`. Many `DepKind`s only require a single `DefId` parameter,
 //!   in which case it is possible to map the node's fingerprint back to the
@@ -400,19 +400,6 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
     // We use this for most things when incr. comp. is turned off.
     [] Null,
 
-    // Represents the `Krate` as a whole (the `hir::Krate` value) (as
-    // distinct from the krate module). This is basically a hash of
-    // the entire krate, so if you read from `Krate` (e.g., by calling
-    // `tcx.hir().krate()`), we will have to assume that any change
-    // means that you need to be recompiled. This is because the
-    // `Krate` value gives you access to all other items. To avoid
-    // this fate, do not call `tcx.hir().krate()`; instead, prefer
-    // wrappers like `tcx.visit_all_items_in_krate()`.  If there is no
-    // suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain
-    // access to the krate, but you must remember to add suitable
-    // edges yourself for the individual items that you read.
-    [eval_always] Krate,
-
     // Represents the body of a function or method. The def-id is that of the
     // function/method.
     [eval_always] HirBody(DefId),
diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs
index b6be4bb0019..4c922654e02 100644
--- a/src/librustc/hir/map/collector.rs
+++ b/src/librustc/hir/map/collector.rs
@@ -223,12 +223,9 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
             (commandline_args_hash, crate_disambiguator.to_fingerprint()),
         );
 
-        let (_, crate_hash) = input_dep_node_and_hash(
-            self.dep_graph,
-            &mut self.hcx,
-            DepNode::new_no_params(DepKind::Krate),
-            crate_hash_input,
-        );
+        let mut stable_hasher = StableHasher::new();
+        crate_hash_input.hash_stable(&mut self.hcx, &mut stable_hasher);
+        let crate_hash: Fingerprint = stable_hasher.finish();
 
         let svh = Svh::new(crate_hash.to_smaller_hash());
         (self.map, svh)
diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs
index 76e42b8af28..da9695ec08a 100644
--- a/src/librustc/hir/map/hir_id_validator.rs
+++ b/src/librustc/hir/map/hir_id_validator.rs
@@ -12,7 +12,7 @@ pub fn check_crate(hir_map: &Map<'_>) {
 
     let errors = Lock::new(Vec::new());
 
-    par_iter(&hir_map.krate().modules).for_each(|(module_id, _)| {
+    par_iter(&hir_map.forest.krate.modules).for_each(|(module_id, _)| {
         let local_def_id = hir_map.local_def_id(*module_id);
         hir_map.visit_item_likes_in_module(
             local_def_id,
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index 6d7f53133a6..0e74ccc63b8 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -140,11 +140,6 @@ impl Forest<'hir> {
         Forest { krate, dep_graph: dep_graph.clone() }
     }
 
-    pub fn krate(&self) -> &Crate<'hir> {
-        self.dep_graph.read(DepNode::new_no_params(DepKind::Krate));
-        &self.krate
-    }
-
     /// This is used internally in the dependency tracking system.
     /// Use the `krate` method to ensure your dependency on the
     /// crate is tracked.
@@ -401,10 +396,6 @@ impl<'hir> Map<'hir> {
         self.lookup(id).cloned()
     }
 
-    pub fn krate(&self) -> &'hir Crate<'hir> {
-        self.forest.krate()
-    }
-
     pub fn item(&self, id: HirId) -> &'hir Item<'hir> {
         self.read(id);
 
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 3a53c0cb282..259cee47160 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -8,7 +8,9 @@ pub mod map;
 
 use crate::ty::query::Providers;
 use crate::ty::TyCtxt;
+use rustc_hir::def_id::LOCAL_CRATE;
 use rustc_hir::print;
+use rustc_hir::Crate;
 use std::ops::Deref;
 
 /// A wrapper type which allows you to access HIR.
@@ -18,6 +20,12 @@ pub struct Hir<'tcx> {
     map: &'tcx map::Map<'tcx>,
 }
 
+impl<'tcx> Hir<'tcx> {
+    pub fn krate(&self) -> &'tcx Crate<'tcx> {
+        self.tcx.hir_crate(LOCAL_CRATE)
+    }
+}
+
 impl<'tcx> Deref for Hir<'tcx> {
     type Target = &'tcx map::Map<'tcx>;
 
diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs
index f0ea9ee7b19..82ff7da13ae 100644
--- a/src/librustc/query/mod.rs
+++ b/src/librustc/query/mod.rs
@@ -43,6 +43,12 @@ rustc_queries! {
     }
 
     Other {
+        // Represents crate as a whole (as distinct from the to-level crate module).
+        // If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`),
+        // we will have to assume that any change means that you need to be recompiled.
+        // This is because the `hir_crate` query gives you access to all other items.
+        // To avoid this fate, do not call `tcx.hir().krate()`; instead,
+        // prefer wrappers like `tcx.visit_all_items_in_krate()`.
         query hir_crate(key: CrateNum) -> &'tcx Crate<'tcx> {
             eval_always
             no_hash
diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs
index 117a38c655e..6d9fff351e9 100644
--- a/src/librustc/ty/query/plumbing.rs
+++ b/src/librustc/ty/query/plumbing.rs
@@ -1177,7 +1177,6 @@ pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
         // These are inputs that are expected to be pre-allocated and that
         // should therefore always be red or green already.
         DepKind::AllLocalTraitImpls |
-        DepKind::Krate |
         DepKind::CrateMetadata |
         DepKind::HirBody |
         DepKind::Hir |
diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs
index 4606ef81a36..d4f01490499 100644
--- a/src/librustc_driver/pretty.rs
+++ b/src/librustc_driver/pretty.rs
@@ -69,19 +69,19 @@ where
     match *ppmode {
         PpmNormal => {
             let annotation = NoAnn { sess: tcx.sess, tcx: Some(tcx) };
-            f(&annotation, tcx.hir().forest.krate())
+            f(&annotation, tcx.hir().krate())
         }
 
         PpmIdentified => {
             let annotation = IdentifiedAnnotation { sess: tcx.sess, tcx: Some(tcx) };
-            f(&annotation, tcx.hir().forest.krate())
+            f(&annotation, tcx.hir().krate())
         }
         PpmTyped => {
             abort_on_err(tcx.analysis(LOCAL_CRATE), tcx.sess);
 
             let empty_tables = ty::TypeckTables::empty(None);
             let annotation = TypedAnnotation { tcx, tables: Cell::new(&empty_tables) };
-            tcx.dep_graph.with_ignore(|| f(&annotation, tcx.hir().forest.krate()))
+            tcx.dep_graph.with_ignore(|| f(&annotation, tcx.hir().krate()))
         }
         _ => panic!("Should use call_with_pp_support"),
     }
diff --git a/src/librustc_resolve/lifetimes.rs b/src/librustc_resolve/lifetimes.rs
index 0ba9b4f1706..87522d28d1e 100644
--- a/src/librustc_resolve/lifetimes.rs
+++ b/src/librustc_resolve/lifetimes.rs
@@ -612,7 +612,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                                 let parent_id = self.tcx.hir().get_parent_node(hir_id);
                                 let parent_impl_id = hir::ImplItemId { hir_id: parent_id };
                                 let parent_trait_id = hir::TraitItemId { hir_id: parent_id };
-                                let krate = self.tcx.hir().forest.krate();
+                                let krate = self.tcx.hir().krate();
 
                                 if !(krate.items.contains_key(&parent_id)
                                     || krate.impl_items.contains_key(&parent_impl_id)
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index ca173fdeb66..80d3cc05fb7 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -87,7 +87,7 @@ pub fn run(options: Options) -> i32 {
         compiler.enter(|queries| {
             let lower_to_hir = queries.lower_to_hir()?;
 
-            let mut opts = scrape_test_config(lower_to_hir.peek().0.krate());
+            let mut opts = scrape_test_config(lower_to_hir.peek().0.untracked_krate());
             opts.display_warnings |= options.display_warnings;
             let enable_per_target_ignores = options.enable_per_target_ignores;
             let mut collector = Collector::new(
diff --git a/src/test/incremental/crate_hash_reorder.rs b/src/test/incremental/crate_hash_reorder.rs
index 5aba2a67037..6e06e67b668 100644
--- a/src/test/incremental/crate_hash_reorder.rs
+++ b/src/test/incremental/crate_hash_reorder.rs
@@ -7,11 +7,9 @@
 
 // Check that reordering otherwise identical items is not considered a
 // change at all.
-#[rustc_clean(label="Krate", cfg="rpass2")]
-
+#[rustc_clean(label = "hir_crate", cfg = "rpass2")]
 // But removing an item, naturally, is.
-#[rustc_dirty(label="Krate", cfg="rpass3")]
-
+#[rustc_dirty(label = "hir_crate", cfg = "rpass3")]
 #[cfg(rpass1)]
 pub struct X {
     pub x: u32,
@@ -26,4 +24,4 @@ pub struct X {
     pub x: u32,
 }
 
-pub fn main() { }
+pub fn main() {}
diff --git a/src/test/incremental/issue-38222.rs b/src/test/incremental/issue-38222.rs
index df08661c150..20d4d4200bc 100644
--- a/src/test/incremental/issue-38222.rs
+++ b/src/test/incremental/issue-38222.rs
@@ -1,18 +1,14 @@
-// Test that debuginfo does not introduce a dependency edge to the Krate
+// Test that debuginfo does not introduce a dependency edge to the hir_crate
 // dep-node.
 
 // revisions:rpass1 rpass2
 // compile-flags: -Z query-dep-graph
 
-
 #![feature(rustc_attrs)]
-
-
-#![rustc_partition_reused(module="issue_38222-mod1", cfg="rpass2")]
-
-// If codegen had added a dependency edge to the Krate dep-node, nothing would
+#![rustc_partition_reused(module = "issue_38222-mod1", cfg = "rpass2")]
+// If codegen had added a dependency edge to the hir_crate 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")]
+#![rustc_partition_reused(module = "issue_38222", cfg = "rpass2")]
 
 //[rpass1] compile-flags: -C debuginfo=1
 //[rpass2] compile-flags: -C debuginfo=1
diff --git a/src/test/incremental/krate-inherent.rs b/src/test/incremental/krate-inherent.rs
index 6e791eacdf3..2c04e110525 100644
--- a/src/test/incremental/krate-inherent.rs
+++ b/src/test/incremental/krate-inherent.rs
@@ -4,20 +4,20 @@
 
 #![allow(warnings)]
 #![feature(rustc_attrs)]
-#![rustc_partition_reused(module="krate_inherent-x", cfg="cfail2")]
+#![rustc_partition_reused(module = "krate_inherent-x", cfg = "cfail2")]
 #![crate_type = "rlib"]
 
 pub mod x {
     pub struct Foo;
     impl Foo {
-        pub fn foo(&self) { }
+        pub fn foo(&self) {}
     }
 
     pub fn method() {
         let x: Foo = Foo;
-        x.foo(); // inherent methods used to add an edge from Krate
+        x.foo(); // inherent methods used to add an edge from hir_crate
     }
 }
 
 #[cfg(cfail1)]
-pub fn bar() { } // remove this unrelated fn in cfail2, which should not affect `x::method`
+pub fn bar() {} // remove this unrelated fn in cfail2, which should not affect `x::method`
diff --git a/src/test/incremental/krate-inlined.rs b/src/test/incremental/krate-inlined.rs
index dfb18166ae9..6b1db74a37c 100644
--- a/src/test/incremental/krate-inlined.rs
+++ b/src/test/incremental/krate-inlined.rs
@@ -1,5 +1,5 @@
 // Regr. test that using HIR inlined from another krate does *not* add
-// a dependency from the local Krate node. We can't easily test that
+// a dependency from the local hir_crate node. We can't easily test that
 // directly anymore, so now we test that we get reuse.
 
 // revisions: rpass1 rpass2
@@ -7,7 +7,7 @@
 
 #![allow(warnings)]
 #![feature(rustc_attrs)]
-#![rustc_partition_reused(module="krate_inlined-x", cfg="rpass2")]
+#![rustc_partition_reused(module = "krate_inlined-x", cfg = "rpass2")]
 
 fn main() {
     x::method();
diff --git a/src/test/ui/dep-graph/dep-graph-variance-alias.rs b/src/test/ui/dep-graph/dep-graph-variance-alias.rs
index 95645687307..927ea559778 100644
--- a/src/test/ui/dep-graph/dep-graph-variance-alias.rs
+++ b/src/test/ui/dep-graph/dep-graph-variance-alias.rs
@@ -6,17 +6,16 @@
 #![feature(rustc_attrs)]
 #![allow(dead_code)]
 #![allow(unused_variables)]
-
-fn main() { }
+#![rustc_if_this_changed(hir_crate)]
+fn main() {}
 
 struct Foo<T> {
-    f: T
+    f: T,
 }
 
-#[rustc_if_this_changed(Krate)]
 type TypeAlias<T> = Foo<T>;
 
 #[rustc_then_this_would_need(variances_of)] //~ ERROR OK
 struct Use<T> {
-    x: TypeAlias<T>
+    x: TypeAlias<T>,
 }
diff --git a/src/test/ui/dep-graph/dep-graph-variance-alias.stderr b/src/test/ui/dep-graph/dep-graph-variance-alias.stderr
index 554ff455a20..2422cb9bb2f 100644
--- a/src/test/ui/dep-graph/dep-graph-variance-alias.stderr
+++ b/src/test/ui/dep-graph/dep-graph-variance-alias.stderr
@@ -1,5 +1,5 @@
 error: OK
-  --> $DIR/dep-graph-variance-alias.rs:19:1
+  --> $DIR/dep-graph-variance-alias.rs:18:1
    |
 LL | #[rustc_then_this_would_need(variances_of)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^