This is a [breaking-change] for plugin authors.
You must now create a dep-graph earlier.
// Represents the HIR node with the given node-id
Hir(D),
- // Represents the meta-data for a node. For local def-ids, this is
- // created by trans. For remote def-ids, we add a read of this
- // node each time we pull the information for an item out of the
- // crate store.
- MetaData(D),
-
// Represents different phases in the compiler.
CrateReader,
CollectLanguageItems,
}
impl Forest {
- pub fn new(krate: Crate, dep_graph: DepGraph) -> Forest {
+ pub fn new(krate: Crate, dep_graph: &DepGraph) -> Forest {
Forest {
krate: krate,
- dep_graph: dep_graph,
+ dep_graph: dep_graph.clone(),
inlined_items: TypedArena::new()
}
}
use session::config::PanicStrategy;
use session::search_paths::PathKind;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
-use std::any::Any;
use std::cell::RefCell;
use std::rc::Rc;
use std::path::PathBuf;
#[cfg(test)]
mod tests {
+ use dep_graph::DepGraph;
use middle::cstore::DummyCrateStore;
use session::config::{build_configuration, build_session_options};
use session::build_session;
// When the user supplies --test we should implicitly supply --cfg test
#[test]
fn test_switch_implies_cfg_test() {
+ let dep_graph = DepGraph::new(false);
let matches =
&match getopts(&["--test".to_string()], &optgroups()) {
Ok(m) => m,
};
let registry = diagnostics::registry::Registry::new(&[]);
let sessopts = build_session_options(matches);
- let sess = build_session(sessopts, None, registry, Rc::new(DummyCrateStore));
+ let sess = build_session(sessopts, &dep_graph, None, registry, Rc::new(DummyCrateStore));
let cfg = build_configuration(&sess);
assert!((attr::contains_name(&cfg[..], "test")));
}
// another --cfg test
#[test]
fn test_switch_implies_cfg_test_unless_cfg_test() {
+ let dep_graph = DepGraph::new(false);
let matches =
&match getopts(&["--test".to_string(), "--cfg=test".to_string()],
&optgroups()) {
};
let registry = diagnostics::registry::Registry::new(&[]);
let sessopts = build_session_options(matches);
- let sess = build_session(sessopts, None, registry,
+ let sess = build_session(sessopts, &dep_graph, None, registry,
Rc::new(DummyCrateStore));
let cfg = build_configuration(&sess);
let mut test_items = cfg.iter().filter(|m| m.name() == "test");
#[test]
fn test_can_print_warnings() {
+ let dep_graph = DepGraph::new(false);
{
let matches = getopts(&[
"-Awarnings".to_string()
], &optgroups()).unwrap();
let registry = diagnostics::registry::Registry::new(&[]);
let sessopts = build_session_options(&matches);
- let sess = build_session(sessopts, None, registry,
+ let sess = build_session(sessopts, &dep_graph, None, registry,
Rc::new(DummyCrateStore));
assert!(!sess.diagnostic().can_emit_warnings);
}
], &optgroups()).unwrap();
let registry = diagnostics::registry::Registry::new(&[]);
let sessopts = build_session_options(&matches);
- let sess = build_session(sessopts, None, registry,
+ let sess = build_session(sessopts, &dep_graph, None, registry,
Rc::new(DummyCrateStore));
assert!(sess.diagnostic().can_emit_warnings);
}
], &optgroups()).unwrap();
let registry = diagnostics::registry::Registry::new(&[]);
let sessopts = build_session_options(&matches);
- let sess = build_session(sessopts, None, registry,
+ let sess = build_session(sessopts, &dep_graph, None, registry,
Rc::new(DummyCrateStore));
assert!(sess.diagnostic().can_emit_warnings);
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use dep_graph::DepGraph;
use lint;
use middle::cstore::CrateStore;
use middle::dependency_format;
// Represents the data associated with a compilation
// session for a single crate.
pub struct Session {
+ pub dep_graph: DepGraph,
pub target: config::Config,
pub host: Target,
pub opts: config::Options,
}
pub fn build_session(sopts: config::Options,
+ dep_graph: &DepGraph,
local_crate_source_file: Option<PathBuf>,
registry: diagnostics::registry::Registry,
cstore: Rc<for<'a> CrateStore<'a>>)
-> Session {
build_session_with_codemap(sopts,
- local_crate_source_file,
- registry,
- cstore,
- Rc::new(codemap::CodeMap::new()))
+ dep_graph,
+ local_crate_source_file,
+ registry,
+ cstore,
+ Rc::new(codemap::CodeMap::new()))
}
pub fn build_session_with_codemap(sopts: config::Options,
+ dep_graph: &DepGraph,
local_crate_source_file: Option<PathBuf>,
registry: diagnostics::registry::Registry,
cstore: Rc<for<'a> CrateStore<'a>>,
treat_err_as_bug,
emitter);
- build_session_(sopts, local_crate_source_file, diagnostic_handler, codemap, cstore)
+ build_session_(sopts,
+ dep_graph,
+ local_crate_source_file,
+ diagnostic_handler,
+ codemap,
+ cstore)
}
pub fn build_session_(sopts: config::Options,
+ dep_graph: &DepGraph,
local_crate_source_file: Option<PathBuf>,
span_diagnostic: errors::Handler,
codemap: Rc<codemap::CodeMap>,
);
let sess = Session {
+ dep_graph: dep_graph.clone(),
target: target_cfg,
host: host,
opts: sopts,
Ok(()));
let expanded_crate = assign_node_ids(sess, expanded_crate);
- let dep_graph = DepGraph::new(sess.opts.build_dep_graph());
// Collect defintions for def ids.
let mut defs = time(sess.time_passes(),
time(sess.time_passes(),
"external crate/lib resolution",
- || read_local_crates(sess, &cstore, &defs, &expanded_crate, &id, &dep_graph));
+ || read_local_crates(sess, &cstore, &defs, &expanded_crate, &id, &sess.dep_graph));
time(sess.time_passes(),
"early lint checks",
|| lint::check_ast_crate(sess, &expanded_crate));
let (analysis, resolutions, mut hir_forest) = {
- lower_and_resolve(sess, &id, &mut defs, &expanded_crate, dep_graph,
- control.make_glob_map)
+ lower_and_resolve(sess, &id, &mut defs, &expanded_crate,
+ &sess.dep_graph, control.make_glob_map)
};
// Discard MTWT tables that aren't required past lowering to HIR.
id: &'a str,
defs: &mut hir_map::Definitions,
krate: &ast::Crate,
- dep_graph: DepGraph,
+ dep_graph: &DepGraph,
make_glob_map: resolve::MakeGlobMap)
-> (ty::CrateAnalysis<'a>, Resolutions, hir_map::Forest) {
resolve::with_resolver(sess, defs, make_glob_map, |mut resolver| {
use rustc_resolve as resolve;
use rustc_save_analysis as save;
use rustc_trans::back::link;
+use rustc::dep_graph::DepGraph;
use rustc::session::{self, config, Session, build_session, CompileResult};
use rustc::session::config::{Input, PrintRequest, OutputType, ErrorOutputType};
use rustc::session::config::{get_unstable_features_setting, nightly_options};
},
};
- let cstore = Rc::new(CStore::new(token::get_ident_interner()));
+ let dep_graph = DepGraph::new(sopts.build_dep_graph());
+ let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
let codemap = Rc::new(CodeMap::with_file_loader(loader));
let sess = session::build_session_with_codemap(sopts,
+ &dep_graph,
input_file_path,
descriptions,
cstore.clone(),
describe_lints(&ls, false);
return None;
}
- let cstore = Rc::new(CStore::new(token::get_ident_interner()));
- let sess = build_session(sopts.clone(), None, descriptions.clone(),
- cstore.clone());
+ let dep_graph = DepGraph::new(sopts.build_dep_graph());
+ let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
+ let sess = build_session(sopts.clone(),
+ &dep_graph,
+ None,
+ descriptions.clone(),
+ cstore.clone());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
let should_stop = RustcDefaultCalls::print_crate_info(&sess, None, odir, ofile);
if should_stop == Compilation::Stop {
use abort_on_err;
use driver::{self, Resolutions};
-use rustc::dep_graph::DepGraph;
use rustc::ty::{self, TyCtxt};
use rustc::cfg;
use rustc::cfg::graphviz::LabelledCFG;
+use rustc::dep_graph::DepGraph;
use rustc::session::Session;
use rustc::session::config::Input;
use rustc_borrowck as borrowck;
options.unstable_features = UnstableFeatures::Allow;
let diagnostic_handler = errors::Handler::with_emitter(true, false, emitter);
- let cstore = Rc::new(CStore::new(token::get_ident_interner()));
- let sess = session::build_session_(options, None, diagnostic_handler,
+ let dep_graph = DepGraph::new(false);
+ let _ignore = dep_graph.in_ignore();
+ let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
+ let sess = session::build_session_(options, &dep_graph, None, diagnostic_handler,
Rc::new(CodeMap::new()), cstore.clone());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
let krate_config = Vec::new();
let krate = driver::phase_2_configure_and_expand(&sess, &cstore, krate, "test", None)
.expect("phase 2 aborted");
- let dep_graph = DepGraph::new(false);
let krate = driver::assign_node_ids(&sess, krate);
let mut defs = hir_map::collect_definitions(&krate);
read_local_crates(&sess, &cstore, &defs, &krate, "test_crate", &dep_graph);
let _ignore = dep_graph.in_ignore();
let (_, resolutions, mut hir_forest) = {
- driver::lower_and_resolve(&sess, "test-crate", &mut defs, &krate, dep_graph.clone(),
- MakeGlobMap::No)
+ driver::lower_and_resolve(&sess, "test-crate", &mut defs, &krate,
+ &sess.dep_graph, MakeGlobMap::No)
};
let arenas = ty::CtxtArenas::new();
use index;
use loader;
+use rustc::dep_graph::DepGraph;
use rustc::hir::def_id::DefId;
use rustc::hir::svh::Svh;
use rustc::middle::cstore::{ExternCrate};
}
pub struct CStore {
+ _dep_graph: DepGraph,
metas: RefCell<FnvHashMap<ast::CrateNum, Rc<crate_metadata>>>,
/// Map from NodeId's of local extern crate statements to crate numbers
extern_mod_crate_map: RefCell<NodeMap<ast::CrateNum>>,
}
impl CStore {
- pub fn new(intr: Rc<IdentInterner>) -> CStore {
+ pub fn new(dep_graph: &DepGraph,
+ intr: Rc<IdentInterner>) -> CStore {
CStore {
+ _dep_graph: dep_graph.clone(),
metas: RefCell::new(FnvHashMap()),
extern_mod_crate_map: RefCell::new(FnvHashMap()),
used_crate_sources: RefCell::new(Vec::new()),
false,
codemap.clone());
- let cstore = Rc::new(CStore::new(token::get_ident_interner()));
- let sess = session::build_session_(sessopts, cpath, diagnostic_handler,
+ let dep_graph = DepGraph::new(false);
+ let _ignore = dep_graph.in_ignore();
+ let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
+ let sess = session::build_session_(sessopts, &dep_graph, cpath, diagnostic_handler,
codemap, cstore.clone());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
.expect("phase_2_configure_and_expand aborted in rustdoc!");
let krate = driver::assign_node_ids(&sess, krate);
- let dep_graph = DepGraph::new(false);
let mut defs = hir_map::collect_definitions(&krate);
read_local_crates(&sess, &cstore, &defs, &krate, &name, &dep_graph);
// Lower ast -> hir and resolve.
let (analysis, resolutions, mut hir_forest) = {
- driver::lower_and_resolve(&sess, &name, &mut defs, &krate, dep_graph,
- resolve::MakeGlobMap::No)
+ driver::lower_and_resolve(&sess, &name, &mut defs, &krate,
+ &sess.dep_graph, resolve::MakeGlobMap::No)
};
let arenas = ty::CtxtArenas::new();
return None
}
- let _ignore = tcx.dep_graph.in_ignore();
let ty::CrateAnalysis { access_levels, .. } = analysis;
// Convert from a NodeId set to a DefId set since we don't always have easy access
false,
codemap.clone());
- let cstore = Rc::new(CStore::new(token::get_ident_interner()));
+ let dep_graph = DepGraph::new(false);
+ let _ignore = dep_graph.in_ignore();
+ let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
let sess = session::build_session_(sessopts,
+ &dep_graph,
Some(input_path.clone()),
diagnostic_handler,
codemap,
let opts = scrape_test_config(&krate);
let _ignore = dep_graph.in_ignore();
- let mut forest = hir_map::Forest::new(krate, dep_graph.clone());
+ let mut forest = hir_map::Forest::new(krate, &dep_graph);
let map = hir_map::map_crate(&mut forest, defs);
let ctx = core::DocContext {
// Compile the code
let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter);
- let cstore = Rc::new(CStore::new(token::get_ident_interner()));
+ let dep_graph = DepGraph::new(false);
+ let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
let sess = session::build_session_(sessopts,
+ &dep_graph,
None,
diagnostic_handler,
codemap,
let handle = thread.spawn(move || {
let opts = build_exec_options(sysroot);
- let cstore = Rc::new(CStore::new(token::get_ident_interner()));
- let sess = build_session(opts, None, Registry::new(&rustc::DIAGNOSTICS),
+ let dep_graph = DepGraph::new(opts.build_dep_graph());
+ let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
+ let sess = build_session(opts,
+ &dep_graph,
+ None,
+ Registry::new(&rustc::DIAGNOSTICS),
cstore.clone());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
let krate = driver::phase_2_configure_and_expand(&sess, &cstore, krate, &id, None)
.expect("phase_2 returned `None`");
- 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);
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)
+ driver::lower_and_resolve(&sess, &id, &mut defs, &krate,
+ &sess.dep_graph, MakeGlobMap::No)
};
let arenas = ty::CtxtArenas::new();
extern crate rustc_metadata;
extern crate syntax;
+use rustc::dep_graph::DepGraph;
use rustc::session::{build_session, Session};
use rustc::session::config::{basic_options, build_configuration, Input, OutputType};
use rustc_driver::driver::{compile_input, CompileController, anon_src};
opts.maybe_sysroot = Some(sysroot);
let descriptions = Registry::new(&rustc::DIAGNOSTICS);
- let cstore = Rc::new(CStore::new(token::get_ident_interner()));
- let sess = build_session(opts, None, descriptions, cstore.clone());
+ let dep_graph = DepGraph::new(opts.build_dep_graph());
+ let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
+ let sess = build_session(opts, &dep_graph, None, descriptions, cstore.clone());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
(sess, cstore)
}