rustc: Remove lang item methods from CrateStore
Given the previous commit, these are now trivially representable as queries!
This commit is contained in:
parent
a2e2aba07d
commit
953490ddfa
11 changed files with 82 additions and 75 deletions
|
|
@ -561,6 +561,8 @@ define_dep_nodes!( <'tcx>
|
|||
[] ItemChildren(DefId),
|
||||
[] ExternModStmtCnum(HirId),
|
||||
[] GetLangItems,
|
||||
[] DefinedLangItems(CrateNum),
|
||||
[] MissingLangItems(CrateNum),
|
||||
);
|
||||
|
||||
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ use hir::map as hir_map;
|
|||
use hir::map::definitions::{Definitions, DefKey, DefPathTable};
|
||||
use hir::svh::Svh;
|
||||
use ich;
|
||||
use middle::lang_items;
|
||||
use ty::{self, TyCtxt};
|
||||
use session::Session;
|
||||
use session::search_paths::PathKind;
|
||||
|
|
@ -243,10 +242,6 @@ pub trait CrateStore {
|
|||
// trait/impl-item info
|
||||
fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem;
|
||||
|
||||
// crate metadata
|
||||
fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>;
|
||||
fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>;
|
||||
|
||||
// resolve
|
||||
fn def_key(&self, def: DefId) -> DefKey;
|
||||
fn def_path(&self, def: DefId) -> hir_map::DefPath;
|
||||
|
|
@ -332,10 +327,6 @@ impl CrateStore for DummyCrateStore {
|
|||
{ bug!("associated_item_cloned") }
|
||||
|
||||
// crate metadata
|
||||
fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>
|
||||
{ bug!("lang_items") }
|
||||
fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>
|
||||
{ bug!("missing_lang_items") }
|
||||
fn dep_kind_untracked(&self, cnum: CrateNum) -> DepKind { bug!("is_explicitly_linked") }
|
||||
fn export_macros_untracked(&self, cnum: CrateNum) { bug!("export_macros") }
|
||||
fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol { bug!("crate_name") }
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<Symbol> {
|
|||
pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LanguageItems {
|
||||
let mut collector = LanguageItemCollector::new(tcx);
|
||||
for cnum in tcx.sess.cstore.crates() {
|
||||
for (index, item_index) in tcx.sess.cstore.lang_items(cnum) {
|
||||
for &(index, item_index) in tcx.defined_lang_items(cnum).iter() {
|
||||
let def_id = DefId { krate: cnum, index: index };
|
||||
collector.collect_item(item_index, def_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
let mut missing = HashSet::new();
|
||||
for cnum in tcx.sess.cstore.crates() {
|
||||
for item in tcx.sess.cstore.missing_lang_items(cnum) {
|
||||
for &item in tcx.missing_lang_items(cnum).iter() {
|
||||
missing.insert(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1097,7 +1097,17 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn lang_items(self) -> Rc<middle::lang_items::LanguageItems> {
|
||||
self.get_lang_items(LOCAL_CRATE)
|
||||
// Right now we insert a `with_ignore` node in the dep graph here to
|
||||
// ignore the fact that `get_lang_items` below depends on the entire
|
||||
// crate. For now this'll prevent false positives of recompiling too
|
||||
// much when anything changes.
|
||||
//
|
||||
// Once red/green incremental compilation lands we should be able to
|
||||
// remove this because while the crate changes often the lint level map
|
||||
// will change rarely.
|
||||
self.dep_graph.with_ignore(|| {
|
||||
self.get_lang_items(LOCAL_CRATE)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
use dep_graph::{DepConstructor, DepNode, DepNodeIndex};
|
||||
use errors::{Diagnostic, DiagnosticBuilder};
|
||||
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex};
|
||||
use hir::def::{Def, Export};
|
||||
use hir::{self, TraitCandidate, HirId};
|
||||
use hir::svh::Svh;
|
||||
|
|
@ -22,7 +22,7 @@ use middle::privacy::AccessLevels;
|
|||
use middle::region;
|
||||
use middle::region::RegionMaps;
|
||||
use middle::resolve_lifetime::{Region, ObjectLifetimeDefault};
|
||||
use middle::lang_items::LanguageItems;
|
||||
use middle::lang_items::{LanguageItems, LangItem};
|
||||
use mir;
|
||||
use mir::transform::{MirSuite, MirPassIndex};
|
||||
use session::CompileResult;
|
||||
|
|
@ -694,6 +694,18 @@ impl<'tcx> QueryDescription for queries::get_lang_items<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::defined_lang_items<'tcx> {
|
||||
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||
format!("calculating the lang items defined in a crate")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::missing_lang_items<'tcx> {
|
||||
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||
format!("calculating the missing lang items in a crate")
|
||||
}
|
||||
}
|
||||
|
||||
// If enabled, send a message to the profile-queries thread
|
||||
macro_rules! profq_msg {
|
||||
($tcx:expr, $msg:expr) => {
|
||||
|
|
@ -1301,6 +1313,8 @@ define_maps! { <'tcx>
|
|||
[] extern_mod_stmt_cnum: ExternModStmtCnum(HirId) -> Option<CrateNum>,
|
||||
|
||||
[] get_lang_items: get_lang_items_node(CrateNum) -> Rc<LanguageItems>,
|
||||
[] defined_lang_items: DefinedLangItems(CrateNum) -> Rc<Vec<(DefIndex, usize)>>,
|
||||
[] missing_lang_items: MissingLangItems(CrateNum) -> Rc<Vec<LangItem>>,
|
||||
}
|
||||
|
||||
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ use rustc::dep_graph::DepGraph;
|
|||
use rustc_lint;
|
||||
use rustc_resolve::MakeGlobMap;
|
||||
use rustc_trans;
|
||||
use rustc::middle::lang_items;
|
||||
use rustc::middle::free_region::FreeRegionMap;
|
||||
use rustc::middle::region;
|
||||
use rustc::middle::resolve_lifetime;
|
||||
|
|
@ -140,7 +139,6 @@ fn test_env<F>(source_string: &str,
|
|||
let hir_map = hir_map::map_crate(&mut hir_forest, defs);
|
||||
|
||||
// run just enough stuff to build a tcx:
|
||||
let lang_items = lang_items::collect_language_items(&sess, &hir_map);
|
||||
let named_region_map = resolve_lifetime::krate(&sess, &hir_map);
|
||||
let index = stability::Index::new(&sess);
|
||||
TyCtxt::create_and_enter(&sess,
|
||||
|
|
@ -152,7 +150,6 @@ fn test_env<F>(source_string: &str,
|
|||
resolutions,
|
||||
named_region_map.unwrap(),
|
||||
hir_map,
|
||||
lang_items,
|
||||
index,
|
||||
"test_crate",
|
||||
|tcx| {
|
||||
|
|
|
|||
|
|
@ -20,11 +20,10 @@ use rustc::middle::cstore::{CrateStore, CrateSource, LibSource, DepKind,
|
|||
LinkagePreference, LoadedMacro, EncodedMetadata,
|
||||
EncodedMetadataHashes, NativeLibraryKind};
|
||||
use rustc::hir::def;
|
||||
use rustc::middle::lang_items;
|
||||
use rustc::session::Session;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::ty::maps::Providers;
|
||||
use rustc::hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE, CRATE_DEF_INDEX};
|
||||
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE, CRATE_DEF_INDEX};
|
||||
use rustc::hir::map::{DefKey, DefPath, DefPathHash};
|
||||
use rustc::hir::map::blocks::FnLikeNode;
|
||||
use rustc::hir::map::definitions::{DefPathTable, GlobalMetaDataKind};
|
||||
|
|
@ -213,6 +212,8 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess);
|
||||
Rc::new(result)
|
||||
}
|
||||
defined_lang_items => { Rc::new(cdata.get_lang_items(&tcx.dep_graph)) }
|
||||
missing_lang_items => { Rc::new(cdata.get_missing_lang_items(&tcx.dep_graph)) }
|
||||
}
|
||||
|
||||
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
|
||||
|
|
@ -305,17 +306,6 @@ impl CrateStore for cstore::CStore {
|
|||
}
|
||||
}
|
||||
|
||||
fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>
|
||||
{
|
||||
self.get_crate_data(cnum).get_lang_items(&self.dep_graph)
|
||||
}
|
||||
|
||||
fn missing_lang_items(&self, cnum: CrateNum)
|
||||
-> Vec<lang_items::LangItem>
|
||||
{
|
||||
self.get_crate_data(cnum).get_missing_lang_items(&self.dep_graph)
|
||||
}
|
||||
|
||||
fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol
|
||||
{
|
||||
self.get_crate_data(cnum).name
|
||||
|
|
|
|||
|
|
@ -243,26 +243,27 @@ pub fn build_impls(cx: &DocContext, did: DefId) -> Vec<clean::Item> {
|
|||
}
|
||||
|
||||
// Also try to inline primitive impls from other crates.
|
||||
let lang_items = tcx.lang_items();
|
||||
let primitive_impls = [
|
||||
tcx.lang_items.isize_impl(),
|
||||
tcx.lang_items.i8_impl(),
|
||||
tcx.lang_items.i16_impl(),
|
||||
tcx.lang_items.i32_impl(),
|
||||
tcx.lang_items.i64_impl(),
|
||||
tcx.lang_items.i128_impl(),
|
||||
tcx.lang_items.usize_impl(),
|
||||
tcx.lang_items.u8_impl(),
|
||||
tcx.lang_items.u16_impl(),
|
||||
tcx.lang_items.u32_impl(),
|
||||
tcx.lang_items.u64_impl(),
|
||||
tcx.lang_items.u128_impl(),
|
||||
tcx.lang_items.f32_impl(),
|
||||
tcx.lang_items.f64_impl(),
|
||||
tcx.lang_items.char_impl(),
|
||||
tcx.lang_items.str_impl(),
|
||||
tcx.lang_items.slice_impl(),
|
||||
tcx.lang_items.const_ptr_impl(),
|
||||
tcx.lang_items.mut_ptr_impl(),
|
||||
lang_items.isize_impl(),
|
||||
lang_items.i8_impl(),
|
||||
lang_items.i16_impl(),
|
||||
lang_items.i32_impl(),
|
||||
lang_items.i64_impl(),
|
||||
lang_items.i128_impl(),
|
||||
lang_items.usize_impl(),
|
||||
lang_items.u8_impl(),
|
||||
lang_items.u16_impl(),
|
||||
lang_items.u32_impl(),
|
||||
lang_items.u64_impl(),
|
||||
lang_items.u128_impl(),
|
||||
lang_items.f32_impl(),
|
||||
lang_items.f64_impl(),
|
||||
lang_items.char_impl(),
|
||||
lang_items.str_impl(),
|
||||
lang_items.slice_impl(),
|
||||
lang_items.const_ptr_impl(),
|
||||
lang_items.mut_ptr_impl(),
|
||||
];
|
||||
|
||||
for def_id in primitive_impls.iter().filter_map(|&def_id| def_id) {
|
||||
|
|
@ -401,7 +402,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
|||
clean::RegionBound(..) => unreachable!(),
|
||||
}
|
||||
});
|
||||
if trait_.def_id() == tcx.lang_items.deref_trait() {
|
||||
if trait_.def_id() == tcx.lang_items().deref_trait() {
|
||||
super::build_deref_target_impls(cx, &trait_items, ret);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,9 +125,9 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
|
|||
|
||||
{
|
||||
let mut r = cx.renderinfo.borrow_mut();
|
||||
r.deref_trait_did = cx.tcx.lang_items.deref_trait();
|
||||
r.deref_mut_trait_did = cx.tcx.lang_items.deref_mut_trait();
|
||||
r.owned_box_did = cx.tcx.lang_items.owned_box();
|
||||
r.deref_trait_did = cx.tcx.lang_items().deref_trait();
|
||||
r.deref_mut_trait_did = cx.tcx.lang_items().deref_mut_trait();
|
||||
r.owned_box_did = cx.tcx.lang_items().owned_box();
|
||||
}
|
||||
|
||||
let mut externs = Vec::new();
|
||||
|
|
@ -689,7 +689,7 @@ impl TyParamBound {
|
|||
fn is_sized_bound(&self, cx: &DocContext) -> bool {
|
||||
use rustc::hir::TraitBoundModifier as TBM;
|
||||
if let TyParamBound::TraitBound(PolyTrait { ref trait_, .. }, TBM::None) = *self {
|
||||
if trait_.def_id() == cx.tcx.lang_items.sized_trait() {
|
||||
if trait_.def_id() == cx.tcx.lang_items().sized_trait() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -713,7 +713,7 @@ fn external_path_params(cx: &DocContext, trait_did: Option<DefId>, has_self: boo
|
|||
|
||||
match trait_did {
|
||||
// Attempt to sugar an external path like Fn<(A, B,), C> to Fn(A, B) -> C
|
||||
Some(did) if cx.tcx.lang_items.fn_trait_kind(did).is_some() => {
|
||||
Some(did) if cx.tcx.lang_items().fn_trait_kind(did).is_some() => {
|
||||
assert_eq!(types.len(), 1);
|
||||
let inputs = match types[0].sty {
|
||||
ty::TyTuple(ref tys, _) => tys.iter().map(|t| t.clean(cx)).collect(),
|
||||
|
|
@ -2526,7 +2526,7 @@ impl Clean<Vec<Item>> for doctree::Impl {
|
|||
|
||||
// If this impl block is an implementation of the Deref trait, then we
|
||||
// need to try inlining the target's inherent impl blocks as well.
|
||||
if trait_.def_id() == cx.tcx.lang_items.deref_trait() {
|
||||
if trait_.def_id() == cx.tcx.lang_items().deref_trait() {
|
||||
build_deref_target_impls(cx, &items, &mut ret);
|
||||
}
|
||||
|
||||
|
|
@ -2582,27 +2582,27 @@ fn build_deref_target_impls(cx: &DocContext,
|
|||
}
|
||||
};
|
||||
let did = match primitive {
|
||||
Isize => tcx.lang_items.isize_impl(),
|
||||
I8 => tcx.lang_items.i8_impl(),
|
||||
I16 => tcx.lang_items.i16_impl(),
|
||||
I32 => tcx.lang_items.i32_impl(),
|
||||
I64 => tcx.lang_items.i64_impl(),
|
||||
I128 => tcx.lang_items.i128_impl(),
|
||||
Usize => tcx.lang_items.usize_impl(),
|
||||
U8 => tcx.lang_items.u8_impl(),
|
||||
U16 => tcx.lang_items.u16_impl(),
|
||||
U32 => tcx.lang_items.u32_impl(),
|
||||
U64 => tcx.lang_items.u64_impl(),
|
||||
U128 => tcx.lang_items.u128_impl(),
|
||||
F32 => tcx.lang_items.f32_impl(),
|
||||
F64 => tcx.lang_items.f64_impl(),
|
||||
Char => tcx.lang_items.char_impl(),
|
||||
Isize => tcx.lang_items().isize_impl(),
|
||||
I8 => tcx.lang_items().i8_impl(),
|
||||
I16 => tcx.lang_items().i16_impl(),
|
||||
I32 => tcx.lang_items().i32_impl(),
|
||||
I64 => tcx.lang_items().i64_impl(),
|
||||
I128 => tcx.lang_items().i128_impl(),
|
||||
Usize => tcx.lang_items().usize_impl(),
|
||||
U8 => tcx.lang_items().u8_impl(),
|
||||
U16 => tcx.lang_items().u16_impl(),
|
||||
U32 => tcx.lang_items().u32_impl(),
|
||||
U64 => tcx.lang_items().u64_impl(),
|
||||
U128 => tcx.lang_items().u128_impl(),
|
||||
F32 => tcx.lang_items().f32_impl(),
|
||||
F64 => tcx.lang_items().f64_impl(),
|
||||
Char => tcx.lang_items().char_impl(),
|
||||
Bool => None,
|
||||
Str => tcx.lang_items.str_impl(),
|
||||
Slice => tcx.lang_items.slice_impl(),
|
||||
Array => tcx.lang_items.slice_impl(),
|
||||
Str => tcx.lang_items().str_impl(),
|
||||
Slice => tcx.lang_items().slice_impl(),
|
||||
Array => tcx.lang_items().slice_impl(),
|
||||
Tuple => None,
|
||||
RawPointer => tcx.lang_items.const_ptr_impl(),
|
||||
RawPointer => tcx.lang_items().const_ptr_impl(),
|
||||
Reference => None,
|
||||
Fn => None,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,3 +16,5 @@
|
|||
|
||||
extern crate core;
|
||||
extern crate weak_lang_items;
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue