mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 19:23:50 +00:00
Make LocalCrateReader private to creader.
This commit is contained in:
parent
5511e6568f
commit
c0e321abcb
@ -28,7 +28,7 @@ use rustc_borrowck as borrowck;
|
|||||||
use rustc_incremental;
|
use rustc_incremental;
|
||||||
use rustc_resolve as resolve;
|
use rustc_resolve as resolve;
|
||||||
use rustc_metadata::macro_import;
|
use rustc_metadata::macro_import;
|
||||||
use rustc_metadata::creader::LocalCrateReader;
|
use rustc_metadata::creader::read_local_crates;
|
||||||
use rustc_metadata::cstore::CStore;
|
use rustc_metadata::cstore::CStore;
|
||||||
use rustc_trans::back::link;
|
use rustc_trans::back::link;
|
||||||
use rustc_trans::back::write;
|
use rustc_trans::back::write;
|
||||||
@ -148,8 +148,7 @@ pub fn compile_input(sess: &Session,
|
|||||||
|
|
||||||
time(sess.time_passes(),
|
time(sess.time_passes(),
|
||||||
"external crate/lib resolution",
|
"external crate/lib resolution",
|
||||||
|| LocalCrateReader::new(sess, &cstore, &defs, &expanded_crate, &id)
|
|| read_local_crates(sess, &cstore, &defs, &expanded_crate, &id, &dep_graph));
|
||||||
.read_crates(&dep_graph));
|
|
||||||
|
|
||||||
time(sess.time_passes(),
|
time(sess.time_passes(),
|
||||||
"early lint checks",
|
"early lint checks",
|
||||||
|
@ -26,7 +26,7 @@ use rustc::traits::ProjectionMode;
|
|||||||
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
|
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||||
use rustc::infer::{self, InferOk, InferResult, TypeOrigin};
|
use rustc::infer::{self, InferOk, InferResult, TypeOrigin};
|
||||||
use rustc_metadata::cstore::CStore;
|
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::hir::map as hir_map;
|
||||||
use rustc::session::{self, config};
|
use rustc::session::{self, config};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -120,7 +120,7 @@ fn test_env<F>(source_string: &str,
|
|||||||
let dep_graph = DepGraph::new(false);
|
let dep_graph = DepGraph::new(false);
|
||||||
let krate = driver::assign_node_ids(&sess, krate);
|
let krate = driver::assign_node_ids(&sess, krate);
|
||||||
let mut defs = hir_map::collect_definitions(&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 _ignore = dep_graph.in_ignore();
|
||||||
|
|
||||||
let (_, resolutions, mut hir_forest) = {
|
let (_, resolutions, mut hir_forest) = {
|
||||||
|
@ -41,7 +41,7 @@ use syntax::parse::token::InternedString;
|
|||||||
use syntax::visit;
|
use syntax::visit;
|
||||||
use log;
|
use log;
|
||||||
|
|
||||||
pub struct LocalCrateReader<'a> {
|
struct LocalCrateReader<'a> {
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
cstore: &'a CStore,
|
cstore: &'a CStore,
|
||||||
creader: CrateReader<'a>,
|
creader: CrateReader<'a>,
|
||||||
@ -841,12 +841,12 @@ impl<'a> CrateReader<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LocalCrateReader<'a> {
|
impl<'a> LocalCrateReader<'a> {
|
||||||
pub fn new(sess: &'a Session,
|
fn new(sess: &'a Session,
|
||||||
cstore: &'a CStore,
|
cstore: &'a CStore,
|
||||||
defs: &'a hir_map::Definitions,
|
defs: &'a hir_map::Definitions,
|
||||||
krate: &'a ast::Crate,
|
krate: &'a ast::Crate,
|
||||||
local_crate_name: &str)
|
local_crate_name: &str)
|
||||||
-> LocalCrateReader<'a> {
|
-> LocalCrateReader<'a> {
|
||||||
LocalCrateReader {
|
LocalCrateReader {
|
||||||
sess: sess,
|
sess: sess,
|
||||||
cstore: cstore,
|
cstore: cstore,
|
||||||
@ -859,7 +859,7 @@ impl<'a> LocalCrateReader<'a> {
|
|||||||
// Traverses an AST, reading all the information about use'd crates and
|
// Traverses an AST, reading all the information about use'd crates and
|
||||||
// extern libraries necessary for later resolving, typechecking, linking,
|
// extern libraries necessary for later resolving, typechecking, linking,
|
||||||
// etc.
|
// 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);
|
let _task = dep_graph.in_task(DepNode::CrateReader);
|
||||||
|
|
||||||
self.process_crate(self.krate);
|
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
|
/// Imports the codemap from an external crate into the codemap of the crate
|
||||||
/// currently being compiled (the "local crate").
|
/// currently being compiled (the "local crate").
|
||||||
///
|
///
|
||||||
|
@ -21,7 +21,7 @@ use rustc::lint;
|
|||||||
use rustc_trans::back::link;
|
use rustc_trans::back::link;
|
||||||
use rustc_resolve as resolve;
|
use rustc_resolve as resolve;
|
||||||
use rustc_metadata::cstore::CStore;
|
use rustc_metadata::cstore::CStore;
|
||||||
use rustc_metadata::creader::LocalCrateReader;
|
use rustc_metadata::creader::read_local_crates;
|
||||||
|
|
||||||
use syntax::{ast, codemap, errors};
|
use syntax::{ast, codemap, errors};
|
||||||
use syntax::errors::emitter::ColorConfig;
|
use syntax::errors::emitter::ColorConfig;
|
||||||
@ -154,7 +154,7 @@ pub fn run_core(search_paths: SearchPaths,
|
|||||||
let dep_graph = DepGraph::new(false);
|
let dep_graph = DepGraph::new(false);
|
||||||
|
|
||||||
let mut defs = hir_map::collect_definitions(&krate);
|
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.
|
// Lower ast -> hir and resolve.
|
||||||
let (analysis, resolutions, mut hir_forest) = {
|
let (analysis, resolutions, mut hir_forest) = {
|
||||||
|
@ -34,7 +34,7 @@ use rustc::session::config::{self, basic_options, build_configuration, Input, Op
|
|||||||
use rustc::session::build_session;
|
use rustc::session::build_session;
|
||||||
use rustc_driver::{driver, abort_on_err};
|
use rustc_driver::{driver, abort_on_err};
|
||||||
use rustc_resolve::MakeGlobMap;
|
use rustc_resolve::MakeGlobMap;
|
||||||
use rustc_metadata::creader::LocalCrateReader;
|
use rustc_metadata::creader::read_local_crates;
|
||||||
use rustc_metadata::cstore::CStore;
|
use rustc_metadata::cstore::CStore;
|
||||||
use libc::c_void;
|
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 dep_graph = DepGraph::new(sess.opts.build_dep_graph());
|
||||||
let krate = driver::assign_node_ids(&sess, krate);
|
let krate = driver::assign_node_ids(&sess, krate);
|
||||||
let mut defs = ast_map::collect_definitions(&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) = {
|
let (analysis, resolutions, mut hir_forest) = {
|
||||||
driver::lower_and_resolve(&sess, &id, &mut defs, &krate, dep_graph, MakeGlobMap::No)
|
driver::lower_and_resolve(&sess, &id, &mut defs, &krate, dep_graph, MakeGlobMap::No)
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user