Make LocalCrateReader private to creader.

This commit is contained in:
Ms2ger 2016-05-10 15:52:33 +02:00
parent 5511e6568f
commit c0e321abcb
5 changed files with 27 additions and 17 deletions

View File

@ -28,7 +28,7 @@ use rustc_borrowck as borrowck;
use rustc_incremental;
use rustc_resolve as resolve;
use rustc_metadata::macro_import;
use rustc_metadata::creader::LocalCrateReader;
use rustc_metadata::creader::read_local_crates;
use rustc_metadata::cstore::CStore;
use rustc_trans::back::link;
use rustc_trans::back::write;
@ -148,8 +148,7 @@ pub fn compile_input(sess: &Session,
time(sess.time_passes(),
"external crate/lib resolution",
|| LocalCrateReader::new(sess, &cstore, &defs, &expanded_crate, &id)
.read_crates(&dep_graph));
|| read_local_crates(sess, &cstore, &defs, &expanded_crate, &id, &dep_graph));
time(sess.time_passes(),
"early lint checks",

View File

@ -26,7 +26,7 @@ use rustc::traits::ProjectionMode;
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc::infer::{self, InferOk, InferResult, TypeOrigin};
use rustc_metadata::cstore::CStore;
use rustc_metadata::creader::LocalCrateReader;
use rustc_metadata::creader::read_local_crates;
use rustc::hir::map as hir_map;
use rustc::session::{self, config};
use std::rc::Rc;
@ -120,7 +120,7 @@ fn test_env<F>(source_string: &str,
let dep_graph = DepGraph::new(false);
let krate = driver::assign_node_ids(&sess, krate);
let mut defs = hir_map::collect_definitions(&krate);
LocalCrateReader::new(&sess, &cstore, &defs, &krate, "test_crate").read_crates(&dep_graph);
read_local_crates(&sess, &cstore, &defs, &krate, "test_crate", &dep_graph);
let _ignore = dep_graph.in_ignore();
let (_, resolutions, mut hir_forest) = {

View File

@ -41,7 +41,7 @@ use syntax::parse::token::InternedString;
use syntax::visit;
use log;
pub struct LocalCrateReader<'a> {
struct LocalCrateReader<'a> {
sess: &'a Session,
cstore: &'a CStore,
creader: CrateReader<'a>,
@ -841,12 +841,12 @@ impl<'a> CrateReader<'a> {
}
impl<'a> LocalCrateReader<'a> {
pub fn new(sess: &'a Session,
cstore: &'a CStore,
defs: &'a hir_map::Definitions,
krate: &'a ast::Crate,
local_crate_name: &str)
-> LocalCrateReader<'a> {
fn new(sess: &'a Session,
cstore: &'a CStore,
defs: &'a hir_map::Definitions,
krate: &'a ast::Crate,
local_crate_name: &str)
-> LocalCrateReader<'a> {
LocalCrateReader {
sess: sess,
cstore: cstore,
@ -859,7 +859,7 @@ impl<'a> LocalCrateReader<'a> {
// Traverses an AST, reading all the information about use'd crates and
// extern libraries necessary for later resolving, typechecking, linking,
// etc.
pub fn read_crates(&mut self, dep_graph: &DepGraph) {
fn read_crates(&mut self, dep_graph: &DepGraph) {
let _task = dep_graph.in_task(DepNode::CrateReader);
self.process_crate(self.krate);
@ -981,6 +981,17 @@ impl<'a> LocalCrateReader<'a> {
}
}
/// Traverses an AST, reading all the information about use'd crates and extern
/// libraries necessary for later resolving, typechecking, linking, etc.
pub fn read_local_crates(sess: & Session,
cstore: & CStore,
defs: & hir_map::Definitions,
krate: & ast::Crate,
local_crate_name: &str,
dep_graph: &DepGraph) {
LocalCrateReader::new(sess, cstore, defs, krate, local_crate_name).read_crates(dep_graph)
}
/// Imports the codemap from an external crate into the codemap of the crate
/// currently being compiled (the "local crate").
///

View File

@ -21,7 +21,7 @@ use rustc::lint;
use rustc_trans::back::link;
use rustc_resolve as resolve;
use rustc_metadata::cstore::CStore;
use rustc_metadata::creader::LocalCrateReader;
use rustc_metadata::creader::read_local_crates;
use syntax::{ast, codemap, errors};
use syntax::errors::emitter::ColorConfig;
@ -154,7 +154,7 @@ pub fn run_core(search_paths: SearchPaths,
let dep_graph = DepGraph::new(false);
let mut defs = hir_map::collect_definitions(&krate);
LocalCrateReader::new(&sess, &cstore, &defs, &krate, &name).read_crates(&dep_graph);
read_local_crates(&sess, &cstore, &defs, &krate, &name, &dep_graph);
// Lower ast -> hir and resolve.
let (analysis, resolutions, mut hir_forest) = {

View File

@ -34,7 +34,7 @@ use rustc::session::config::{self, basic_options, build_configuration, Input, Op
use rustc::session::build_session;
use rustc_driver::{driver, abort_on_err};
use rustc_resolve::MakeGlobMap;
use rustc_metadata::creader::LocalCrateReader;
use rustc_metadata::creader::read_local_crates;
use rustc_metadata::cstore::CStore;
use libc::c_void;
@ -240,7 +240,7 @@ fn compile_program(input: &str, sysroot: PathBuf)
let dep_graph = DepGraph::new(sess.opts.build_dep_graph());
let krate = driver::assign_node_ids(&sess, krate);
let mut defs = ast_map::collect_definitions(&krate);
LocalCrateReader::new(&sess, &cstore, &defs, &krate, &id).read_crates(&dep_graph);
read_local_crates(&sess, &cstore, &defs, &krate, &id, &dep_graph);
let (analysis, resolutions, mut hir_forest) = {
driver::lower_and_resolve(&sess, &id, &mut defs, &krate, dep_graph, MakeGlobMap::No)
};