Avoid passing around the thread-local interner in librustc_metadata.
This commit is contained in:
parent
1eb6d0b485
commit
70e2845230
10 changed files with 69 additions and 132 deletions
|
|
@ -97,7 +97,7 @@ use rustc::session::early_error;
|
|||
use syntax::{ast, json};
|
||||
use syntax::codemap::{CodeMap, FileLoader, RealFileLoader};
|
||||
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
|
||||
use syntax::parse::{self, PResult, token};
|
||||
use syntax::parse::{self, PResult};
|
||||
use syntax_pos::MultiSpan;
|
||||
use errors::emitter::Emitter;
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ pub fn run_compiler_with_file_loader<'a, L>(args: &[String],
|
|||
};
|
||||
|
||||
let dep_graph = DepGraph::new(sopts.build_dep_graph());
|
||||
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
|
||||
let cstore = Rc::new(CStore::new(&dep_graph));
|
||||
let codemap = Rc::new(CodeMap::with_file_loader(loader));
|
||||
let sess = session::build_session_with_codemap(sopts,
|
||||
&dep_graph,
|
||||
|
|
@ -432,7 +432,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
|||
return None;
|
||||
}
|
||||
let dep_graph = DepGraph::new(sopts.build_dep_graph());
|
||||
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
|
||||
let cstore = Rc::new(CStore::new(&dep_graph));
|
||||
let sess = build_session(sopts.clone(),
|
||||
&dep_graph,
|
||||
None,
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ fn test_env<F>(source_string: &str,
|
|||
|
||||
let dep_graph = DepGraph::new(false);
|
||||
let _ignore = dep_graph.in_ignore();
|
||||
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
|
||||
let cstore = Rc::new(CStore::new(&dep_graph));
|
||||
let sess = session::build_session_(options, &dep_graph, None, diagnostic_handler,
|
||||
Rc::new(CodeMap::new()), cstore.clone());
|
||||
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
|
||||
|
|
|
|||
|
|
@ -557,7 +557,6 @@ impl<'a> CrateReader<'a> {
|
|||
let source_name = format!("<{} macros>", item.ident);
|
||||
let mut macros = vec![];
|
||||
decoder::each_exported_macro(ekrate.metadata.as_slice(),
|
||||
&self.cstore.intr,
|
||||
|name, attrs, span, body| {
|
||||
// NB: Don't use parse::parse_tts_from_source_str because it parses with
|
||||
// quote_depth > 0.
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
{
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_adt_def(&self.intr, &cdata, def.index, tcx)
|
||||
decoder::get_adt_def(&cdata, def.index, tcx)
|
||||
}
|
||||
|
||||
fn method_arg_names(&self, did: DefId) -> Vec<String>
|
||||
|
|
@ -140,13 +140,13 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
fn item_name(&self, def: DefId) -> ast::Name {
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_item_name(&self.intr, &cdata, def.index)
|
||||
decoder::get_item_name(&cdata, def.index)
|
||||
}
|
||||
|
||||
fn opt_item_name(&self, def: DefId) -> Option<ast::Name> {
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::maybe_get_item_name(&self.intr, &cdata, def.index)
|
||||
decoder::maybe_get_item_name(&cdata, def.index)
|
||||
}
|
||||
|
||||
fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId>
|
||||
|
|
@ -176,7 +176,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
{
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_provided_trait_methods(self.intr.clone(), &cdata, def.index, tcx)
|
||||
decoder::get_provided_trait_methods(&cdata, def.index, tcx)
|
||||
}
|
||||
|
||||
fn trait_item_def_ids(&self, def: DefId)
|
||||
|
|
@ -222,7 +222,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
-> Vec<Rc<ty::AssociatedConst<'tcx>>> {
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_associated_consts(self.intr.clone(), &cdata, def.index, tcx)
|
||||
decoder::get_associated_consts(&cdata, def.index, tcx)
|
||||
}
|
||||
|
||||
fn impl_parent(&self, impl_def: DefId) -> Option<DefId> {
|
||||
|
|
@ -243,11 +243,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
{
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_impl_or_trait_item(
|
||||
self.intr.clone(),
|
||||
&cdata,
|
||||
def.index,
|
||||
tcx)
|
||||
decoder::get_impl_or_trait_item(&cdata, def.index, tcx)
|
||||
}
|
||||
|
||||
fn is_const_fn(&self, did: DefId) -> bool
|
||||
|
|
@ -460,7 +456,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
{
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_struct_field_names(&self.intr, &cdata, def.index)
|
||||
decoder::get_struct_field_names(&cdata, def.index)
|
||||
}
|
||||
|
||||
fn item_children(&self, def_id: DefId) -> Vec<ChildItem>
|
||||
|
|
@ -469,14 +465,9 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
let mut result = vec![];
|
||||
let crate_data = self.get_crate_data(def_id.krate);
|
||||
let get_crate_data = |cnum| self.get_crate_data(cnum);
|
||||
decoder::each_child_of_item(
|
||||
self.intr.clone(), &crate_data,
|
||||
def_id.index, get_crate_data,
|
||||
|def, name, vis| result.push(ChildItem {
|
||||
def: def,
|
||||
name: name,
|
||||
vis: vis
|
||||
}));
|
||||
decoder::each_child_of_item(&crate_data, def_id.index, get_crate_data, |def, name, vis| {
|
||||
result.push(ChildItem { def: def, name: name, vis: vis });
|
||||
});
|
||||
result
|
||||
}
|
||||
|
||||
|
|
@ -485,13 +476,9 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
let mut result = vec![];
|
||||
let crate_data = self.get_crate_data(cnum);
|
||||
let get_crate_data = |cnum| self.get_crate_data(cnum);
|
||||
decoder::each_top_level_item_of_crate(
|
||||
self.intr.clone(), &crate_data, get_crate_data,
|
||||
|def, name, vis| result.push(ChildItem {
|
||||
def: def,
|
||||
name: name,
|
||||
vis: vis
|
||||
}));
|
||||
decoder::each_top_level_item_of_crate(&crate_data, get_crate_data, |def, name, vis| {
|
||||
result.push(ChildItem { def: def, name: name, vis: vis });
|
||||
});
|
||||
result
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ use flate::Bytes;
|
|||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap;
|
||||
use syntax::parse::token::IdentInterner;
|
||||
use syntax_pos;
|
||||
|
||||
pub use middle::cstore::{NativeLibraryKind, LinkagePreference};
|
||||
|
|
@ -106,13 +105,11 @@ pub struct CStore {
|
|||
used_libraries: RefCell<Vec<(String, NativeLibraryKind)>>,
|
||||
used_link_args: RefCell<Vec<String>>,
|
||||
statically_included_foreign_items: RefCell<NodeSet>,
|
||||
pub intr: Rc<IdentInterner>,
|
||||
pub visible_parent_map: RefCell<DefIdMap<DefId>>,
|
||||
}
|
||||
|
||||
impl CStore {
|
||||
pub fn new(dep_graph: &DepGraph,
|
||||
intr: Rc<IdentInterner>) -> CStore {
|
||||
pub fn new(dep_graph: &DepGraph) -> CStore {
|
||||
CStore {
|
||||
dep_graph: dep_graph.clone(),
|
||||
metas: RefCell::new(FnvHashMap()),
|
||||
|
|
@ -120,7 +117,6 @@ impl CStore {
|
|||
used_crate_sources: RefCell::new(Vec::new()),
|
||||
used_libraries: RefCell::new(Vec::new()),
|
||||
used_link_args: RefCell::new(Vec::new()),
|
||||
intr: intr,
|
||||
statically_included_foreign_items: RefCell::new(NodeSet()),
|
||||
visible_parent_map: RefCell::new(FnvHashMap()),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ use rbml::reader;
|
|||
use rbml;
|
||||
use rustc_serialize::Decodable;
|
||||
use syntax::attr;
|
||||
use syntax::parse::token::{self, IdentInterner};
|
||||
use syntax::parse::token;
|
||||
use syntax::ast;
|
||||
use syntax::abi::Abi;
|
||||
use syntax::codemap;
|
||||
|
|
@ -284,17 +284,14 @@ fn item_trait_ref<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx, 'tcx>, cdata:
|
|||
doc_trait_ref(tp, tcx, cdata)
|
||||
}
|
||||
|
||||
fn item_name(intr: &IdentInterner, item: rbml::Doc) -> ast::Name {
|
||||
maybe_item_name(intr, item).expect("no item in item_name")
|
||||
fn item_name(item: rbml::Doc) -> ast::Name {
|
||||
maybe_item_name(item).expect("no item in item_name")
|
||||
}
|
||||
|
||||
fn maybe_item_name(intr: &IdentInterner, item: rbml::Doc) -> Option<ast::Name> {
|
||||
fn maybe_item_name(item: rbml::Doc) -> Option<ast::Name> {
|
||||
reader::maybe_get_doc(item, tag_paths_data_name).map(|name| {
|
||||
let string = name.as_str_slice();
|
||||
match intr.find(string) {
|
||||
None => token::intern(string),
|
||||
Some(val) => val,
|
||||
}
|
||||
token::intern(string)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -400,8 +397,7 @@ pub fn get_trait_def<'a, 'tcx>(cdata: Cmd,
|
|||
associated_type_names)
|
||||
}
|
||||
|
||||
pub fn get_adt_def<'a, 'tcx>(intr: &IdentInterner,
|
||||
cdata: Cmd,
|
||||
pub fn get_adt_def<'a, 'tcx>(cdata: Cmd,
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::AdtDefMaster<'tcx>
|
||||
|
|
@ -412,9 +408,7 @@ pub fn get_adt_def<'a, 'tcx>(intr: &IdentInterner,
|
|||
_ => bug!("unexpected family: {:?}", family),
|
||||
}
|
||||
}
|
||||
fn get_enum_variants<'tcx>(intr: &IdentInterner,
|
||||
cdata: Cmd,
|
||||
doc: rbml::Doc) -> Vec<ty::VariantDefData<'tcx, 'tcx>> {
|
||||
fn get_enum_variants<'tcx>(cdata: Cmd, doc: rbml::Doc) -> Vec<ty::VariantDefData<'tcx, 'tcx>> {
|
||||
let mut disr_val = 0;
|
||||
reader::tagged_docs(doc, tag_items_data_item_variant).map(|p| {
|
||||
let did = translated_def_id(cdata, p);
|
||||
|
|
@ -428,16 +422,14 @@ pub fn get_adt_def<'a, 'tcx>(intr: &IdentInterner,
|
|||
|
||||
ty::VariantDefData {
|
||||
did: did,
|
||||
name: item_name(intr, item),
|
||||
fields: get_variant_fields(intr, cdata, item),
|
||||
name: item_name(item),
|
||||
fields: get_variant_fields(cdata, item),
|
||||
disr_val: ConstInt::Infer(disr),
|
||||
kind: expect_variant_kind(item_family(item)),
|
||||
}
|
||||
}).collect()
|
||||
}
|
||||
fn get_variant_fields<'tcx>(intr: &IdentInterner,
|
||||
cdata: Cmd,
|
||||
doc: rbml::Doc) -> Vec<ty::FieldDefData<'tcx, 'tcx>> {
|
||||
fn get_variant_fields<'tcx>(cdata: Cmd, doc: rbml::Doc) -> Vec<ty::FieldDefData<'tcx, 'tcx>> {
|
||||
let mut index = 0;
|
||||
reader::tagged_docs(doc, tag_item_field).map(|f| {
|
||||
let ff = item_family(f);
|
||||
|
|
@ -446,24 +438,23 @@ pub fn get_adt_def<'a, 'tcx>(intr: &IdentInterner,
|
|||
_ => bug!("expected field, found {:?}", ff)
|
||||
};
|
||||
ty::FieldDefData::new(item_def_id(f, cdata),
|
||||
item_name(intr, f),
|
||||
item_name(f),
|
||||
struct_field_family_to_visibility(ff))
|
||||
}).chain(reader::tagged_docs(doc, tag_item_unnamed_field).map(|f| {
|
||||
let ff = item_family(f);
|
||||
let name = intr.intern(index.to_string());
|
||||
let name = token::get_ident_interner().intern(index.to_string());
|
||||
index += 1;
|
||||
ty::FieldDefData::new(item_def_id(f, cdata), name,
|
||||
struct_field_family_to_visibility(ff))
|
||||
})).collect()
|
||||
}
|
||||
fn get_struct_variant<'tcx>(intr: &IdentInterner,
|
||||
cdata: Cmd,
|
||||
fn get_struct_variant<'tcx>(cdata: Cmd,
|
||||
doc: rbml::Doc,
|
||||
did: DefId) -> ty::VariantDefData<'tcx, 'tcx> {
|
||||
ty::VariantDefData {
|
||||
did: did,
|
||||
name: item_name(intr, doc),
|
||||
fields: get_variant_fields(intr, cdata, doc),
|
||||
name: item_name(doc),
|
||||
fields: get_variant_fields(cdata, doc),
|
||||
disr_val: ConstInt::Infer(0),
|
||||
kind: expect_variant_kind(item_family(doc)),
|
||||
}
|
||||
|
|
@ -475,7 +466,7 @@ pub fn get_adt_def<'a, 'tcx>(intr: &IdentInterner,
|
|||
let (kind, variants) = match item_family(doc) {
|
||||
Enum => {
|
||||
(ty::AdtKind::Enum,
|
||||
get_enum_variants(intr, cdata, doc))
|
||||
get_enum_variants(cdata, doc))
|
||||
}
|
||||
Struct(..) => {
|
||||
// Use separate constructor id for unit/tuple structs and reuse did for braced structs.
|
||||
|
|
@ -483,7 +474,7 @@ pub fn get_adt_def<'a, 'tcx>(intr: &IdentInterner,
|
|||
translated_def_id(cdata, ctor_doc)
|
||||
});
|
||||
(ty::AdtKind::Struct,
|
||||
vec![get_struct_variant(intr, cdata, doc, ctor_did.unwrap_or(did))])
|
||||
vec![get_struct_variant(cdata, doc, ctor_did.unwrap_or(did))])
|
||||
}
|
||||
_ => bug!("get_adt_def called on a non-ADT {:?} - {:?}",
|
||||
item_family(doc), did)
|
||||
|
|
@ -663,8 +654,7 @@ pub fn each_lang_item<F>(cdata: Cmd, mut f: F) -> bool where
|
|||
})
|
||||
}
|
||||
|
||||
fn each_child_of_item_or_crate<F, G>(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
fn each_child_of_item_or_crate<F, G>(cdata: Cmd,
|
||||
item_doc: rbml::Doc,
|
||||
mut get_crate_data: G,
|
||||
mut callback: F) where
|
||||
|
|
@ -690,7 +680,7 @@ fn each_child_of_item_or_crate<F, G>(intr: Rc<IdentInterner>,
|
|||
// Get the item.
|
||||
if let Some(child_item_doc) = crate_data.get_item(child_def_id.index) {
|
||||
// Hand off the item to the callback.
|
||||
let child_name = item_name(&intr, child_item_doc);
|
||||
let child_name = item_name(child_item_doc);
|
||||
let def_like = item_to_def_like(crate_data, child_item_doc, child_def_id);
|
||||
let visibility = item_visibility(child_item_doc);
|
||||
callback(def_like, child_name, visibility);
|
||||
|
|
@ -711,7 +701,7 @@ fn each_child_of_item_or_crate<F, G>(intr: Rc<IdentInterner>,
|
|||
if let Some(impl_method_doc) = cdata.get_item(impl_item_def_id.index) {
|
||||
if let StaticMethod = item_family(impl_method_doc) {
|
||||
// Hand off the static method to the callback.
|
||||
let static_method_name = item_name(&intr, impl_method_doc);
|
||||
let static_method_name = item_name(impl_method_doc);
|
||||
let static_method_def_like = item_to_def_like(cdata, impl_method_doc,
|
||||
impl_item_def_id);
|
||||
callback(static_method_def_like,
|
||||
|
|
@ -755,13 +745,9 @@ fn each_child_of_item_or_crate<F, G>(intr: Rc<IdentInterner>,
|
|||
}
|
||||
|
||||
/// Iterates over each child of the given item.
|
||||
pub fn each_child_of_item<F, G>(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
id: DefIndex,
|
||||
get_crate_data: G,
|
||||
callback: F) where
|
||||
F: FnMut(DefLike, ast::Name, ty::Visibility),
|
||||
G: FnMut(ast::CrateNum) -> Rc<CrateMetadata>,
|
||||
pub fn each_child_of_item<F, G>(cdata: Cmd, id: DefIndex, get_crate_data: G, callback: F)
|
||||
where F: FnMut(DefLike, ast::Name, ty::Visibility),
|
||||
G: FnMut(ast::CrateNum) -> Rc<CrateMetadata>,
|
||||
{
|
||||
// Find the item.
|
||||
let item_doc = match cdata.get_item(id) {
|
||||
|
|
@ -769,40 +755,31 @@ pub fn each_child_of_item<F, G>(intr: Rc<IdentInterner>,
|
|||
Some(item_doc) => item_doc,
|
||||
};
|
||||
|
||||
each_child_of_item_or_crate(intr,
|
||||
cdata,
|
||||
item_doc,
|
||||
get_crate_data,
|
||||
callback)
|
||||
each_child_of_item_or_crate(cdata, item_doc, get_crate_data, callback)
|
||||
}
|
||||
|
||||
/// Iterates over all the top-level crate items.
|
||||
pub fn each_top_level_item_of_crate<F, G>(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
get_crate_data: G,
|
||||
callback: F) where
|
||||
F: FnMut(DefLike, ast::Name, ty::Visibility),
|
||||
G: FnMut(ast::CrateNum) -> Rc<CrateMetadata>,
|
||||
pub fn each_top_level_item_of_crate<F, G>(cdata: Cmd, get_crate_data: G, callback: F)
|
||||
where F: FnMut(DefLike, ast::Name, ty::Visibility),
|
||||
G: FnMut(ast::CrateNum) -> Rc<CrateMetadata>,
|
||||
{
|
||||
let root_doc = rbml::Doc::new(cdata.data());
|
||||
let misc_info_doc = reader::get_doc(root_doc, tag_misc_info);
|
||||
let crate_items_doc = reader::get_doc(misc_info_doc,
|
||||
tag_misc_info_crate_items);
|
||||
|
||||
each_child_of_item_or_crate(intr,
|
||||
cdata,
|
||||
each_child_of_item_or_crate(cdata,
|
||||
crate_items_doc,
|
||||
get_crate_data,
|
||||
callback)
|
||||
}
|
||||
|
||||
pub fn get_item_name(intr: &IdentInterner, cdata: Cmd, id: DefIndex) -> ast::Name {
|
||||
item_name(intr, cdata.lookup_item(id))
|
||||
pub fn get_item_name(cdata: Cmd, id: DefIndex) -> ast::Name {
|
||||
item_name(cdata.lookup_item(id))
|
||||
}
|
||||
|
||||
pub fn maybe_get_item_name(intr: &IdentInterner, cdata: Cmd, id: DefIndex)
|
||||
-> Option<ast::Name> {
|
||||
maybe_item_name(intr, cdata.lookup_item(id))
|
||||
pub fn maybe_get_item_name(cdata: Cmd, id: DefIndex) -> Option<ast::Name> {
|
||||
maybe_item_name(cdata.lookup_item(id))
|
||||
}
|
||||
|
||||
pub fn maybe_get_item_ast<'a, 'tcx>(cdata: Cmd, tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefIndex)
|
||||
|
|
@ -955,12 +932,9 @@ pub fn get_impl_items(cdata: Cmd, impl_id: DefIndex)
|
|||
}).collect()
|
||||
}
|
||||
|
||||
pub fn get_trait_name(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
id: DefIndex)
|
||||
-> ast::Name {
|
||||
pub fn get_trait_name(cdata: Cmd, id: DefIndex) -> ast::Name {
|
||||
let doc = cdata.lookup_item(id);
|
||||
item_name(&intr, doc)
|
||||
item_name(doc)
|
||||
}
|
||||
|
||||
pub fn is_static_method(cdata: Cmd, id: DefIndex) -> bool {
|
||||
|
|
@ -973,10 +947,7 @@ pub fn is_static_method(cdata: Cmd, id: DefIndex) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_impl_or_trait_item<'a, 'tcx>(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
pub fn get_impl_or_trait_item<'a, 'tcx>(cdata: Cmd, id: DefIndex, tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Option<ty::ImplOrTraitItem<'tcx>> {
|
||||
let item_doc = cdata.lookup_item(id);
|
||||
|
||||
|
|
@ -993,7 +964,7 @@ pub fn get_impl_or_trait_item<'a, 'tcx>(intr: Rc<IdentInterner>,
|
|||
_ => ImplContainer(container_id),
|
||||
};
|
||||
|
||||
let name = item_name(&intr, item_doc);
|
||||
let name = item_name(item_doc);
|
||||
let vis = item_visibility(item_doc);
|
||||
let defaultness = item_defaultness(item_doc);
|
||||
|
||||
|
|
@ -1068,8 +1039,7 @@ pub fn get_item_variances(cdata: Cmd, id: DefIndex) -> ty::ItemVariances {
|
|||
Decodable::decode(&mut decoder).unwrap()
|
||||
}
|
||||
|
||||
pub fn get_provided_trait_methods<'a, 'tcx>(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
pub fn get_provided_trait_methods<'a, 'tcx>(cdata: Cmd,
|
||||
id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Vec<Rc<ty::Method<'tcx>>> {
|
||||
|
|
@ -1080,10 +1050,7 @@ pub fn get_provided_trait_methods<'a, 'tcx>(intr: Rc<IdentInterner>,
|
|||
let mth = cdata.lookup_item(did.index);
|
||||
|
||||
if item_sort(mth) == Some('p') {
|
||||
let trait_item = get_impl_or_trait_item(intr.clone(),
|
||||
cdata,
|
||||
did.index,
|
||||
tcx);
|
||||
let trait_item = get_impl_or_trait_item(cdata, did.index, tcx);
|
||||
if let Some(ty::MethodTraitItem(ref method)) = trait_item {
|
||||
Some((*method).clone())
|
||||
} else {
|
||||
|
|
@ -1095,10 +1062,7 @@ pub fn get_provided_trait_methods<'a, 'tcx>(intr: Rc<IdentInterner>,
|
|||
}).collect()
|
||||
}
|
||||
|
||||
pub fn get_associated_consts<'a, 'tcx>(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
pub fn get_associated_consts<'a, 'tcx>(cdata: Cmd, id: DefIndex, tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Vec<Rc<ty::AssociatedConst<'tcx>>> {
|
||||
let item = cdata.lookup_item(id);
|
||||
|
||||
|
|
@ -1109,10 +1073,7 @@ pub fn get_associated_consts<'a, 'tcx>(intr: Rc<IdentInterner>,
|
|||
|
||||
match item_sort(ac_doc) {
|
||||
Some('C') | Some('c') => {
|
||||
let trait_item = get_impl_or_trait_item(intr.clone(),
|
||||
cdata,
|
||||
did.index,
|
||||
tcx);
|
||||
let trait_item = get_impl_or_trait_item(cdata, did.index, tcx);
|
||||
if let Some(ty::ConstTraitItem(ref ac)) = trait_item {
|
||||
Some((*ac).clone())
|
||||
} else {
|
||||
|
|
@ -1180,14 +1141,13 @@ fn struct_field_family_to_visibility(family: Family) -> ty::Visibility {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_struct_field_names(intr: &IdentInterner, cdata: Cmd, id: DefIndex)
|
||||
-> Vec<ast::Name> {
|
||||
pub fn get_struct_field_names(cdata: Cmd, id: DefIndex) -> Vec<ast::Name> {
|
||||
let item = cdata.lookup_item(id);
|
||||
let mut index = 0;
|
||||
reader::tagged_docs(item, tag_item_field).map(|an_item| {
|
||||
item_name(intr, an_item)
|
||||
item_name(an_item)
|
||||
}).chain(reader::tagged_docs(item, tag_item_unnamed_field).map(|_| {
|
||||
let name = intr.intern(index.to_string());
|
||||
let name = token::get_ident_interner().intern(index.to_string());
|
||||
index += 1;
|
||||
name
|
||||
})).collect()
|
||||
|
|
@ -1503,12 +1463,12 @@ pub fn get_plugin_registrar_fn(data: &[u8]) -> Option<DefIndex> {
|
|||
.map(|doc| DefIndex::from_u32(reader::doc_as_u32(doc)))
|
||||
}
|
||||
|
||||
pub fn each_exported_macro<F>(data: &[u8], intr: &IdentInterner, mut f: F) where
|
||||
pub fn each_exported_macro<F>(data: &[u8], mut f: F) where
|
||||
F: FnMut(ast::Name, Vec<ast::Attribute>, Span, String) -> bool,
|
||||
{
|
||||
let macros = reader::get_doc(rbml::Doc::new(data), tag_macro_defs);
|
||||
for macro_doc in reader::tagged_docs(macros, tag_macro_def) {
|
||||
let name = item_name(intr, macro_doc);
|
||||
let name = item_name(macro_doc);
|
||||
let attrs = get_attributes(macro_doc);
|
||||
let span = get_macro_span(macro_doc);
|
||||
let body = reader::get_doc(macro_doc, tag_macro_def_body);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ use rustc_metadata::cstore::CStore;
|
|||
|
||||
use syntax::{ast, codemap};
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
use syntax::parse::token;
|
||||
use errors;
|
||||
use errors::emitter::ColorConfig;
|
||||
|
||||
|
|
@ -136,7 +135,7 @@ pub fn run_core(search_paths: SearchPaths,
|
|||
|
||||
let dep_graph = DepGraph::new(false);
|
||||
let _ignore = dep_graph.in_ignore();
|
||||
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
|
||||
let cstore = Rc::new(CStore::new(&dep_graph));
|
||||
let sess = session::build_session_(sessopts, &dep_graph, cpath, diagnostic_handler,
|
||||
codemap, cstore.clone());
|
||||
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ use rustc_resolve::MakeGlobMap;
|
|||
use syntax::codemap::CodeMap;
|
||||
use errors;
|
||||
use errors::emitter::ColorConfig;
|
||||
use syntax::parse::token;
|
||||
|
||||
use core;
|
||||
use clean;
|
||||
|
|
@ -82,7 +81,7 @@ pub fn run(input: &str,
|
|||
|
||||
let dep_graph = DepGraph::new(false);
|
||||
let _ignore = dep_graph.in_ignore();
|
||||
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
|
||||
let cstore = Rc::new(CStore::new(&dep_graph));
|
||||
let sess = session::build_session_(sessopts,
|
||||
&dep_graph,
|
||||
Some(input_path.clone()),
|
||||
|
|
@ -239,7 +238,7 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
|
|||
let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter);
|
||||
|
||||
let dep_graph = DepGraph::new(false);
|
||||
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
|
||||
let cstore = Rc::new(CStore::new(&dep_graph));
|
||||
let sess = session::build_session_(sessopts,
|
||||
&dep_graph,
|
||||
None,
|
||||
|
|
|
|||
|
|
@ -30,18 +30,16 @@ use std::thread::Builder;
|
|||
|
||||
use rustc::dep_graph::DepGraph;
|
||||
use rustc::hir::map as ast_map;
|
||||
use rustc::middle::cstore::{CrateStore, LinkagePreference};
|
||||
use rustc::middle::cstore::LinkagePreference;
|
||||
use rustc::ty;
|
||||
use rustc::session::config::{self, basic_options, build_configuration, Input, Options};
|
||||
use rustc::session::build_session;
|
||||
use rustc_driver::{driver, abort_on_err};
|
||||
use rustc_resolve::MakeGlobMap;
|
||||
use rustc_metadata::creader::read_local_crates;
|
||||
use rustc_metadata::cstore::CStore;
|
||||
use libc::c_void;
|
||||
|
||||
use rustc_errors::registry::Registry;
|
||||
use syntax::parse::token;
|
||||
|
||||
fn main() {
|
||||
// Currently trips an assertion on i686-msvc, presumably because the support
|
||||
|
|
@ -226,7 +224,7 @@ fn compile_program(input: &str, sysroot: PathBuf)
|
|||
let handle = thread.spawn(move || {
|
||||
let opts = build_exec_options(sysroot);
|
||||
let dep_graph = DepGraph::new(opts.build_dep_graph());
|
||||
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
|
||||
let cstore = Rc::new(CStore::new(&dep_graph));
|
||||
let sess = build_session(opts,
|
||||
&dep_graph,
|
||||
None,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ use rustc::session::config::{basic_options, build_configuration, Input, OutputTy
|
|||
use rustc_driver::driver::{compile_input, CompileController, anon_src};
|
||||
use rustc_metadata::cstore::CStore;
|
||||
use rustc_errors::registry::Registry;
|
||||
use syntax::parse::token;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -57,7 +56,7 @@ fn basic_sess(sysroot: PathBuf) -> (Session, Rc<CStore>) {
|
|||
|
||||
let descriptions = Registry::new(&rustc::DIAGNOSTICS);
|
||||
let dep_graph = DepGraph::new(opts.build_dep_graph());
|
||||
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
|
||||
let cstore = Rc::new(CStore::new(&dep_graph));
|
||||
let sess = build_session(opts, &dep_graph, None, descriptions, cstore.clone());
|
||||
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
|
||||
(sess, cstore)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue