-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Minor refactoring and features in rustc driver for embedders #15820
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4ec97fb
rustc: Make `monitor` public.
brson a232626
rustc: Extract --crate-type parsing to its own function
brson df102ef
rustc: Pass optional additional plugins to compile_input
brson 7d87b53
rustc: Allow the crate linked to as 'std' to be customized
brson d9c60f4
Address review feedback
brson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,8 @@ pub fn compile_input(sess: Session, | |
cfg: ast::CrateConfig, | ||
input: &Input, | ||
outdir: &Option<Path>, | ||
output: &Option<Path>) { | ||
output: &Option<Path>, | ||
addl_plugins: Option<Plugins>) { | ||
// We need nested scopes here, because the intermediate results can keep | ||
// large chunks of memory alive and we want to free them as soon as | ||
// possible to keep the peak memory usage low | ||
|
@@ -85,7 +86,8 @@ pub fn compile_input(sess: Session, | |
let id = link::find_crate_name(Some(&sess), krate.attrs.as_slice(), | ||
input); | ||
let (expanded_crate, ast_map) | ||
= match phase_2_configure_and_expand(&sess, krate, id.as_slice()) { | ||
= match phase_2_configure_and_expand(&sess, krate, id.as_slice(), | ||
addl_plugins) { | ||
None => return, | ||
Some(p) => p, | ||
}; | ||
|
@@ -179,14 +181,16 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input) | |
// modified | ||
|
||
/// Run the "early phases" of the compiler: initial `cfg` processing, | ||
/// loading compiler plugins (including those from `addl_plugins`), | ||
/// syntax expansion, secondary `cfg` expansion, synthesis of a test | ||
/// harness if one is to be provided and injection of a dependency on the | ||
/// standard library and prelude. | ||
/// | ||
/// Returns `None` if we're aborting after handling -W help. | ||
pub fn phase_2_configure_and_expand(sess: &Session, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you adjust the doc comment on this to include something like "initial |
||
mut krate: ast::Crate, | ||
crate_name: &str) | ||
crate_name: &str, | ||
addl_plugins: Option<Plugins>) | ||
-> Option<(ast::Crate, syntax::ast_map::Map)> { | ||
let time_passes = sess.time_passes(); | ||
|
||
|
@@ -212,9 +216,10 @@ pub fn phase_2_configure_and_expand(sess: &Session, | |
krate = time(time_passes, "configuration 1", krate, |krate| | ||
front::config::strip_unconfigured_items(krate)); | ||
|
||
let mut addl_plugins = Some(addl_plugins); | ||
let Plugins { macros, registrars } | ||
= time(time_passes, "plugin loading", (), |_| | ||
plugin::load::load_plugins(sess, &krate)); | ||
plugin::load::load_plugins(sess, &krate, addl_plugins.take_unwrap())); | ||
|
||
let mut registry = Registry::new(&krate); | ||
|
||
|
@@ -697,7 +702,7 @@ pub fn pretty_print_input(sess: Session, | |
PpmExpanded | PpmExpandedIdentified | PpmTyped | PpmFlowGraph(_) => { | ||
let (krate, ast_map) | ||
= match phase_2_configure_and_expand(&sess, krate, | ||
id.as_slice()) { | ||
id.as_slice(), None) { | ||
None => return, | ||
Some(p) => p, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a doc-comment here?