Allow CompilerControllers to access rustc_plugin::registry::Registry structure.
This commit is contained in:
parent
d128e6bc74
commit
ca5dfd0c97
@ -97,7 +97,7 @@ macro_rules! controller_entry_point {
|
||||
}
|
||||
};
|
||||
|
||||
let krate = {
|
||||
let (krate, registry) = {
|
||||
let mut compile_state = CompileState::state_after_parse(input,
|
||||
sess,
|
||||
outdir,
|
||||
@ -109,14 +109,14 @@ macro_rules! controller_entry_point {
|
||||
compile_state,
|
||||
Ok(()));
|
||||
|
||||
compile_state.krate.unwrap()
|
||||
(compile_state.krate.unwrap(), compile_state.registry)
|
||||
};
|
||||
|
||||
let outputs = build_output_filenames(input, outdir, output, &krate.attrs, sess);
|
||||
let crate_name = link::find_crate_name(Some(sess), &krate.attrs, input);
|
||||
let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = {
|
||||
phase_2_configure_and_expand(
|
||||
sess, &cstore, krate, &crate_name, addl_plugins, control.make_glob_map,
|
||||
sess, &cstore, krate, registry, &crate_name, addl_plugins, control.make_glob_map,
|
||||
|expanded_crate| {
|
||||
let mut state = CompileState::state_after_expand(
|
||||
input, sess, outdir, output, &cstore, expanded_crate, &crate_name,
|
||||
@ -329,6 +329,7 @@ pub struct CompileState<'a, 'b, 'ast: 'a, 'tcx: 'b> where 'ast: 'tcx {
|
||||
pub input: &'a Input,
|
||||
pub session: &'ast Session,
|
||||
pub krate: Option<ast::Crate>,
|
||||
pub registry: Option<Registry<'a>>,
|
||||
pub cstore: Option<&'a CStore>,
|
||||
pub crate_name: Option<&'a str>,
|
||||
pub output_filenames: Option<&'a OutputFilenames>,
|
||||
@ -357,6 +358,7 @@ fn empty(input: &'a Input,
|
||||
out_file: None,
|
||||
arenas: None,
|
||||
krate: None,
|
||||
registry: None,
|
||||
cstore: None,
|
||||
crate_name: None,
|
||||
output_filenames: None,
|
||||
@ -379,6 +381,8 @@ fn state_after_parse(input: &'a Input,
|
||||
cstore: &'a CStore)
|
||||
-> CompileState<'a, 'b, 'ast, 'tcx> {
|
||||
CompileState {
|
||||
// Initialize the registry before moving `krate`
|
||||
registry: Some(Registry::new(&session, krate.span)),
|
||||
krate: Some(krate),
|
||||
cstore: Some(cstore),
|
||||
out_file: out_file.as_ref().map(|s| &**s),
|
||||
@ -545,6 +549,7 @@ pub struct ExpansionResult<'a> {
|
||||
pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
|
||||
cstore: &CStore,
|
||||
mut krate: ast::Crate,
|
||||
registry: Option<Registry>,
|
||||
crate_name: &'a str,
|
||||
addl_plugins: Option<Vec<String>>,
|
||||
make_glob_map: MakeGlobMap,
|
||||
@ -592,7 +597,7 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
|
||||
addl_plugins.take().unwrap())
|
||||
});
|
||||
|
||||
let mut registry = Registry::new(sess, &krate);
|
||||
let mut registry = registry.unwrap_or(Registry::new(sess, krate.span));
|
||||
|
||||
time(time_passes, "plugin registration", || {
|
||||
if sess.features.borrow().rustc_diagnostic_macros {
|
||||
|
@ -115,7 +115,7 @@ fn test_env<F>(source_string: &str,
|
||||
let krate = driver::phase_1_parse_input(&sess, krate_config, &input).unwrap();
|
||||
let driver::ExpansionResult { defs, resolutions, mut hir_forest, .. } = {
|
||||
driver::phase_2_configure_and_expand(
|
||||
&sess, &cstore, krate, "test", None, MakeGlobMap::No, |_| Ok(()),
|
||||
&sess, &cstore, krate, None, "test", None, MakeGlobMap::No, |_| Ok(()),
|
||||
).expect("phase 2 aborted")
|
||||
};
|
||||
let _ignore = dep_graph.in_ignore();
|
||||
|
@ -69,11 +69,11 @@ pub struct Registry<'a> {
|
||||
|
||||
impl<'a> Registry<'a> {
|
||||
#[doc(hidden)]
|
||||
pub fn new(sess: &'a Session, krate: &ast::Crate) -> Registry<'a> {
|
||||
pub fn new(sess: &'a Session, krate_span: Span) -> Registry<'a> {
|
||||
Registry {
|
||||
sess: sess,
|
||||
args_hidden: None,
|
||||
krate_span: krate.span,
|
||||
krate_span: krate_span,
|
||||
syntax_exts: vec!(),
|
||||
early_lint_passes: vec!(),
|
||||
late_lint_passes: vec!(),
|
||||
|
@ -146,7 +146,7 @@ pub fn run_core(search_paths: SearchPaths,
|
||||
|
||||
let driver::ExpansionResult { defs, analysis, resolutions, mut hir_forest, .. } = {
|
||||
driver::phase_2_configure_and_expand(
|
||||
&sess, &cstore, krate, &name, None, resolve::MakeGlobMap::No, |_| Ok(()),
|
||||
&sess, &cstore, krate, None, &name, None, resolve::MakeGlobMap::No, |_| Ok(()),
|
||||
).expect("phase_2_configure_and_expand aborted in rustdoc!")
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ pub fn run(input: &str,
|
||||
let krate = panictry!(driver::phase_1_parse_input(&sess, cfg, &input));
|
||||
let driver::ExpansionResult { defs, mut hir_forest, .. } = {
|
||||
phase_2_configure_and_expand(
|
||||
&sess, &cstore, krate, "rustdoc-test", None, MakeGlobMap::No, |_| Ok(())
|
||||
&sess, &cstore, krate, None, "rustdoc-test", None, MakeGlobMap::No, |_| Ok(())
|
||||
).expect("phase_2_configure_and_expand aborted in rustdoc!")
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user