Skip to content

Commit

Permalink
Make LocalCrateReader private to creader.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed May 11, 2016
1 parent 5511e65 commit c0e321a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
5 changes: 2 additions & 3 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_driver/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) = {
Expand Down
27 changes: 19 additions & 8 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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").
///
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) = {
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-make/execution-engine/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
};
Expand Down

0 comments on commit c0e321a

Please sign in to comment.