Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CompilerControllers to access rustc_plugin::registry::Registry #36240

Merged
merged 1 commit into from
Sep 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn compile_input(sess: &Session,
}
};

let krate = {
let (krate, registry) = {
let mut compile_state = CompileState::state_after_parse(input,
sess,
outdir,
Expand All @@ -109,14 +109,14 @@ pub fn compile_input(sess: &Session,
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,
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -357,6 +358,7 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
out_file: None,
arenas: None,
krate: None,
registry: None,
cstore: None,
crate_name: None,
output_filenames: None,
Expand All @@ -379,6 +381,8 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_plugin/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
};

Expand Down