Skip to content

Commit

Permalink
add CStore::item_generics_num_lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Jan 9, 2020
1 parent b743af6 commit 5dafa6a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PartialRes>;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
8 changes: 4 additions & 4 deletions src/librustc_metadata/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,17 +478,17 @@ 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 {
fn as_any(&self) -> &dyn Any {
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
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 5dafa6a

Please sign in to comment.