From 5dafa6a46466ab26b7cd7c38f965d37af045af5d Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 9 Jan 2020 09:23:44 +0100 Subject: [PATCH] add CStore::item_generics_num_lifetimes --- src/librustc/middle/cstore.rs | 5 ++--- src/librustc_ast_lowering/lib.rs | 2 +- src/librustc_ast_lowering/path.rs | 2 +- src/librustc_metadata/creader.rs | 3 +-- src/librustc_metadata/rmeta/decoder/cstore_impl.rs | 8 ++++---- src/librustc_resolve/lib.rs | 4 ++-- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index ee43c35c1d05b..5b1e7673629b1 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -5,8 +5,8 @@ use crate::hir::map as hir_map; use crate::hir::map::definitions::{DefKey, DefPathTable}; use crate::session::search_paths::PathKind; -use crate::session::{CrateDisambiguator, Session}; -use crate::ty::{self, TyCtxt}; +use crate::session::CrateDisambiguator; +use crate::ty::TyCtxt; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::{self, MetadataRef}; @@ -208,7 +208,6 @@ pub trait CrateStore { fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool; fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator; fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh; - fn item_generics_cloned_untracked(&self, def: DefId, sess: &Session) -> ty::Generics; // This is basically a 1-based range of ints, which is a little // silly - I may fix that. diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index 2064a3c92f22c..0edc51f1aa4ec 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -173,7 +173,7 @@ struct LoweringContext<'a, 'hir: 'a> { pub trait Resolver { fn def_key(&mut self, id: DefId) -> DefKey; - fn item_generics_num_liftimes(&self, def: DefId, sess: &Session) -> usize; + fn item_generics_num_lifetimes(&self, def: DefId, sess: &Session) -> usize; /// Obtains resolution for a `NodeId` with a single resolution. fn get_partial_res(&mut self, id: NodeId) -> Option; diff --git a/src/librustc_ast_lowering/path.rs b/src/librustc_ast_lowering/path.rs index f6b33de83a2b9..9b504704ae06c 100644 --- a/src/librustc_ast_lowering/path.rs +++ b/src/librustc_ast_lowering/path.rs @@ -93,7 +93,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { return n; } assert!(!def_id.is_local()); - let n = self.resolver.item_generics_num_liftimes(def_id, self.sess); + let n = self.resolver.item_generics_num_lifetimes(def_id, self.sess); self.type_def_lifetime_params.insert(def_id, n); n }); diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index b21715fadfe6f..30d049d143eab 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -12,8 +12,7 @@ use rustc::session::{CrateDisambiguator, Session}; use rustc::ty::TyCtxt; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::Lrc; -use rustc_hir::def_id::CrateNum; -use rustc_hir::def_id::LOCAL_CRATE; +use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_index::vec::IndexVec; use rustc_target::spec::{PanicStrategy, TargetTriple}; diff --git a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs index ba3c4e4aff443..eb5754bf99bfb 100644 --- a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs +++ b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs @@ -478,6 +478,10 @@ impl CStore { pub fn crate_source_untracked(&self, cnum: CrateNum) -> CrateSource { self.get_crate_data(cnum).source.clone() } + + pub fn item_generics_num_lifetimes(&self, def_id: DefId, sess: &Session) -> usize { + self.get_crate_data(def_id.krate).get_generics(def_id.index, sess).own_counts().lifetimes + } } impl CrateStore for CStore { @@ -485,10 +489,6 @@ impl CrateStore for CStore { self } - fn item_generics_cloned_untracked(&self, def: DefId, sess: &Session) -> ty::Generics { - self.get_crate_data(def.krate).get_generics(def.index, sess) - } - fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol { self.get_crate_data(cnum).root.name } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 0a4011fe3f404..9e4486e16f2cc 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1031,8 +1031,8 @@ impl rustc_ast_lowering::Resolver for Resolver<'_> { if id.is_local() { self.definitions().def_key(id.index) } else { self.cstore().def_key(id) } } - fn item_generics_num_liftimes(&self, def_id: DefId, sess: &Session) -> usize { - self.cstore().item_generics_cloned_untracked(def_id, sess).own_counts().lifetimes + fn item_generics_num_lifetimes(&self, def_id: DefId, sess: &Session) -> usize { + self.cstore().item_generics_num_lifetimes(def_id, sess) } fn resolve_str_path(