use syntax::ptr::P;
use rustc_back::target::Target;
use rustc_front::hir;
-use rustc_front::visit::Visitor;
+use rustc_front::intravisit::Visitor;
use rustc_front::util::IdVisitor;
pub use self::DefLike::{DlDef, DlField, DlImpl};
NotFound,
}
+/// A store of Rust crates, through with their metadata
+/// can be accessed.
+///
+/// The `: Any` bound is a temporary measure that allows access
+/// to the backing `rustc_metadata::cstore::CStore` object. It
+/// will be removed in the near future - if you need to access
+/// internal APIs, please tell us.
pub trait CrateStore<'tcx> : Any {
// item info
fn stability(&self, def: DefId) -> Option<attr::Stability>;
}
pub fn visit_ids<O: IdVisitingOperation>(&self, operation: &mut O) {
- let mut id_visitor = IdVisitor {
- operation: operation,
- pass_through_items: true,
- visited_outermost: false,
- };
+ let mut id_visitor = IdVisitor::new(operation);
self.visit(&mut id_visitor);
}
}
const BUG_REPORT_URL: &'static str = "https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.\
md#bug-reports";
-// [stage0]: kill this
+// SNAP 1af31d4
+// This is a terrible hack. Our stage0 is older than 1.4 and does not
+// support DST coercions, so this function performs the corecion
+// manually. This should go away.
pub fn cstore_to_cratestore(a: Rc<CStore>) -> Rc<for<'s> CrateStore<'s>>
{
use std::mem;
use rustc::back::svh::Svh;
use rustc::session::{config, Session};
use rustc::session::search_paths::PathKind;
-use rustc::middle::cstore::validate_crate_name;
+use rustc::middle::cstore::{CrateStore, validate_crate_name};
use rustc::util::nodemap::FnvHashMap;
use rustc::front::map as hir_map;
// We're also sure to compare *paths*, not actual byte slices. The
// `source` stores paths which are normalized which may be different
// from the strings on the command line.
- let source = self.cstore.do_get_used_crate_source(cnum).unwrap();
+ let source = self.cstore.used_crate_source(cnum);
if let Some(locs) = self.sess.opts.externs.get(name) {
let found = locs.iter().any(|l| {
let l = fs::canonicalize(l).ok();
if explicitly_linked && !data.explicitly_linked.get() {
data.explicitly_linked.set(explicitly_linked);
}
- (cnum, data, self.cstore.do_get_used_crate_source(cnum).unwrap())
+ (cnum, data, self.cstore.used_crate_source(cnum))
}
LookupResult::Loaded(library) => {
self.register_crate(root, ident, name, span, library,
}
impl<'a, 'b> LocalCrateReader<'a, 'b> {
- pub fn new(sess: &'a Session, cstore: &'a CStore, map: &'a hir_map::Map<'b>) -> LocalCrateReader<'a, 'b> {
+ pub fn new(sess: &'a Session, cstore: &'a CStore,
+ map: &'a hir_map::Map<'b>) -> LocalCrateReader<'a, 'b> {
LocalCrateReader {
sess: sess,
cstore: cstore,
fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource
{
- self.do_get_used_crate_source(cnum).unwrap()
+ self.opt_used_crate_source(cnum).unwrap()
}
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>
{
- self.find_extern_mod_stmt_cnum(emod_id)
+ self.do_extern_mod_stmt_cnum(emod_id)
}
fn encode_metadata(&self,
I: FnMut(ast::CrateNum, &crate_metadata, Option<CrateSource>),
{
for (&k, v) in self.metas.borrow().iter() {
- let origin = self.do_get_used_crate_source(k);
+ let origin = self.opt_used_crate_source(k);
origin.as_ref().map(|cs| { assert!(k == cs.cnum); });
i(k, &**v, origin);
}
}
}
- // TODO: killdo
- pub fn do_get_used_crate_source(&self, cnum: ast::CrateNum)
- -> Option<CrateSource> {
+ pub fn opt_used_crate_source(&self, cnum: ast::CrateNum)
+ -> Option<CrateSource> {
self.used_crate_sources.borrow_mut()
.iter().find(|source| source.cnum == cnum).cloned()
}
// In order to get this left-to-right dependency ordering, we perform a
// topological sort of all crates putting the leaves at the right-most
// positions.
- // TODO: killdo
pub fn do_get_used_crates(&self, prefer: LinkagePreference)
-> Vec<(ast::CrateNum, Option<PathBuf>)> {
let mut ordering = Vec::new();
self.extern_mod_crate_map.borrow_mut().insert(emod_id, cnum);
}
- pub fn find_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId)
- -> Option<ast::CrateNum> {
- self.extern_mod_crate_map.borrow().get(&emod_id).cloned()
- }
-
pub fn add_statically_included_foreign_item(&self, id: ast::NodeId) {
self.statically_included_foreign_items.borrow_mut().insert(id);
}
pub fn do_is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool {
self.statically_included_foreign_items.borrow().contains(&id)
}
+
+ pub fn do_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>
+ {
+ self.extern_mod_crate_map.borrow().get(&emod_id).cloned()
+ }
}
impl crate_metadata {
_ => panic!("bad function"),
};
- let constness = if csearch::is_const_fn(&tcx.sess.cstore, did) {
+ let constness = if tcx.sess.cstore.is_const_fn(did) {
hir::Constness::Const
} else {
hir::Constness::NotConst
clean::TyMethodItem(clean::TyMethod {
unsafety, decl, self_, generics, abi
}) => {
- let constness = if csearch::is_const_fn(&tcx.sess.cstore, did) {
+ let constness = if tcx.sess.cstore.is_const_fn(did) {
hir::Constness::Const
} else {
hir::Constness::NotConst
//~^ ERROR `CONST` is not directly importable
use use_from_trait_xc::Foo::new;
-//~^ ERROR `new` is not directly importable
+//~^ ERROR unresolved import `use_from_trait_xc::Foo::new`
use use_from_trait_xc::Foo::C;
//~^ ERROR unresolved import `use_from_trait_xc::Foo::C`
use use_from_trait_xc::Bar::new as bnew;
-//~^ ERROR `bnew` is not directly importable
+//~^ ERROR unresolved import `use_from_trait_xc::Bar::new`
use use_from_trait_xc::Baz::new as baznew;
//~^ ERROR `baznew` is not directly importable