From c0e321abcbc25c47e55a808628fb7e65b3fe0f98 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 10 May 2016 15:52:33 +0200 Subject: [PATCH] Make LocalCrateReader private to creader. --- src/librustc_driver/driver.rs | 5 ++-- src/librustc_driver/test.rs | 4 ++-- src/librustc_metadata/creader.rs | 27 +++++++++++++++------- src/librustdoc/core.rs | 4 ++-- src/test/run-make/execution-engine/test.rs | 4 ++-- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index a979410ca94de..d2a5e12009ec4 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -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", diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 270376bda766e..5c62d236844ee 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -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(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) = { diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 62c208dbcb2a4..63c6af704bbfe 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -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"). /// diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index e5919a4b35ff6..67eb268af08f6 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -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) = { diff --git a/src/test/run-make/execution-engine/test.rs b/src/test/run-make/execution-engine/test.rs index a2893fa2f0dc0..0ad113b8d8b38 100644 --- a/src/test/run-make/execution-engine/test.rs +++ b/src/test/run-make/execution-engine/test.rs @@ -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) };