about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-01-06 07:34:52 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-01-09 08:57:24 +0100
commit7472f9ef134465c8d077269236f09e8ef5767772 (patch)
tree3432846501724eba9879d152eaed75d330f5ab22
parent402907f27390edd0d6c8b73c3521f18a1e2c76d5 (diff)
downloadrust-7472f9ef134465c8d077269236f09e8ef5767772.tar.gz
rust-7472f9ef134465c8d077269236f09e8ef5767772.zip
lowering: remove dep on CrateStore
-rw-r--r--src/librustc_ast_lowering/lib.rs13
-rw-r--r--src/librustc_ast_lowering/path.rs8
-rw-r--r--src/librustc_resolve/lib.rs10
3 files changed, 13 insertions, 18 deletions
diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs
index f5d051618e2..d2a51c5d9cc 100644
--- a/src/librustc_ast_lowering/lib.rs
+++ b/src/librustc_ast_lowering/lib.rs
@@ -39,7 +39,6 @@ use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions};
 use rustc::hir::map::Map;
 use rustc::lint;
 use rustc::lint::builtin;
-use rustc::middle::cstore::CrateStore;
 use rustc::{bug, span_bug};
 use rustc_data_structures::captures::Captures;
 use rustc_data_structures::fx::FxHashSet;
@@ -172,7 +171,9 @@ struct LoweringContext<'a, 'hir: 'a> {
 }
 
 pub trait Resolver {
-    fn cstore(&self) -> &dyn CrateStore;
+    fn def_key(&mut self, id: DefId) -> DefKey;
+
+    fn item_generics_cloned_untracked_liftimes(&self, def: DefId, sess: &Session) -> usize;
 
     /// Obtains resolution for a `NodeId` with a single resolution.
     fn get_partial_res(&mut self, id: NodeId) -> Option<PartialRes>;
@@ -936,14 +937,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
         ret
     }
 
-    fn def_key(&mut self, id: DefId) -> DefKey {
-        if id.is_local() {
-            self.resolver.definitions().def_key(id.index)
-        } else {
-            self.resolver.cstore().def_key(id)
-        }
-    }
-
     fn lower_attrs(&mut self, attrs: &[Attribute]) -> &'hir [Attribute] {
         self.arena.alloc_from_iter(attrs.iter().map(|a| self.lower_attr(a)))
     }
diff --git a/src/librustc_ast_lowering/path.rs b/src/librustc_ast_lowering/path.rs
index 4f71910b0bf..b4c196a254e 100644
--- a/src/librustc_ast_lowering/path.rs
+++ b/src/librustc_ast_lowering/path.rs
@@ -49,7 +49,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                     // which may need lifetime elision performed.
                     let parent_def_id = |this: &mut Self, def_id: DefId| DefId {
                         krate: def_id.krate,
-                        index: this.def_key(def_id).parent.expect("missing parent"),
+                        index: this.resolver.def_key(def_id).parent.expect("missing parent"),
                     };
                     let type_def_id = match partial_res.base_res() {
                         Res::Def(DefKind::AssocTy, def_id) if i + 2 == proj_start => {
@@ -93,11 +93,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                             return n;
                         }
                         assert!(!def_id.is_local());
-                        let item_generics = self
+                        let n = self
                             .resolver
-                            .cstore()
-                            .item_generics_cloned_untracked(def_id, self.sess);
-                        let n = item_generics.own_counts().lifetimes;
+                            .item_generics_cloned_untracked_liftimes(def_id, self.sess);
                         self.type_def_lifetime_params.insert(def_id, n);
                         n
                     });
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index f8e42724df7..8a6248aba86 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -22,7 +22,7 @@ use Determinacy::*;
 
 use errors::{struct_span_err, Applicability, DiagnosticBuilder};
 use rustc::hir::exports::ExportMap;
-use rustc::hir::map::Definitions;
+use rustc::hir::map::{DefKey, Definitions};
 use rustc::lint;
 use rustc::middle::cstore::{CrateStore, MetadataLoaderDyn};
 use rustc::session::Session;
@@ -1027,8 +1027,12 @@ impl<'a, 'b> DefIdTree for &'a Resolver<'b> {
 /// This interface is used through the AST→HIR step, to embed full paths into the HIR. After that
 /// the resolver is no longer needed as all the relevant information is inline.
 impl rustc_ast_lowering::Resolver for Resolver<'_> {
-    fn cstore(&self) -> &dyn CrateStore {
-        self.cstore()
+    fn def_key(&mut self, id: DefId) -> DefKey {
+        if id.is_local() { self.definitions().def_key(id.index) } else { self.cstore().def_key(id) }
+    }
+
+    fn item_generics_cloned_untracked_liftimes(&self, def_id: DefId, sess: &Session) -> usize {
+        self.cstore().item_generics_cloned_untracked(def_id, sess).own_counts().lifetimes
     }
 
     fn resolve_str_path(