introduce "early passes" an convert a few over
This commit is contained in:
parent
aaec1014d8
commit
d3d6f76887
6 changed files with 150 additions and 74 deletions
|
@ -97,8 +97,6 @@ mod visit_lib;
|
|||
mod test;
|
||||
mod theme;
|
||||
|
||||
use clean::AttributesExt;
|
||||
|
||||
struct Output {
|
||||
krate: clean::Crate,
|
||||
renderinfo: html::render::RenderInfo,
|
||||
|
@ -631,7 +629,7 @@ fn rust_input<R, F>(cratefile: PathBuf,
|
|||
where R: 'static + Send,
|
||||
F: 'static + Send + FnOnce(Output) -> R
|
||||
{
|
||||
let mut default_passes = if matches.opt_present("no-defaults") {
|
||||
let default_passes = if matches.opt_present("no-defaults") {
|
||||
passes::DefaultPassOption::None
|
||||
} else if matches.opt_present("document-private-items") {
|
||||
passes::DefaultPassOption::Private
|
||||
|
@ -639,8 +637,8 @@ where R: 'static + Send,
|
|||
passes::DefaultPassOption::Default
|
||||
};
|
||||
|
||||
let mut manual_passes = matches.opt_strs("passes");
|
||||
let mut plugins = matches.opt_strs("plugins");
|
||||
let manual_passes = matches.opt_strs("passes");
|
||||
let plugins = matches.opt_strs("plugins");
|
||||
|
||||
// First, parse the crate and extract all relevant information.
|
||||
let mut paths = SearchPaths::new();
|
||||
|
@ -674,11 +672,11 @@ where R: 'static + Send,
|
|||
let result = rustc_driver::monitor(move || syntax::with_globals(move || {
|
||||
use rustc::session::config::Input;
|
||||
|
||||
let (mut krate, renderinfo) =
|
||||
let (mut krate, renderinfo, passes) =
|
||||
core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
|
||||
display_warnings, crate_name.clone(),
|
||||
force_unstable_if_unmarked, edition, cg, error_format,
|
||||
lint_opts, lint_cap, describe_lints);
|
||||
lint_opts, lint_cap, describe_lints, manual_passes, default_passes);
|
||||
|
||||
info!("finished with rustc");
|
||||
|
||||
|
@ -688,58 +686,6 @@ where R: 'static + Send,
|
|||
|
||||
krate.version = crate_version;
|
||||
|
||||
let diag = core::new_handler(error_format, None);
|
||||
|
||||
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
|
||||
let mut msg = diag.struct_warn(&format!("the `#![doc({})]` attribute is \
|
||||
considered deprecated", name));
|
||||
msg.warn("please see https://github.com/rust-lang/rust/issues/44136");
|
||||
|
||||
if name == "no_default_passes" {
|
||||
msg.help("you may want to use `#![doc(document_private_items)]`");
|
||||
}
|
||||
|
||||
msg.emit();
|
||||
}
|
||||
|
||||
// Process all of the crate attributes, extracting plugin metadata along
|
||||
// with the passes which we are supposed to run.
|
||||
for attr in krate.module.as_ref().unwrap().attrs.lists("doc") {
|
||||
let name = attr.name().map(|s| s.as_str());
|
||||
let name = name.as_ref().map(|s| &s[..]);
|
||||
if attr.is_word() {
|
||||
if name == Some("no_default_passes") {
|
||||
report_deprecated_attr("no_default_passes", &diag);
|
||||
if default_passes == passes::DefaultPassOption::Default {
|
||||
default_passes = passes::DefaultPassOption::None;
|
||||
}
|
||||
}
|
||||
} else if let Some(value) = attr.value_str() {
|
||||
let sink = match name {
|
||||
Some("passes") => {
|
||||
report_deprecated_attr("passes = \"...\"", &diag);
|
||||
&mut manual_passes
|
||||
},
|
||||
Some("plugins") => {
|
||||
report_deprecated_attr("plugins = \"...\"", &diag);
|
||||
&mut plugins
|
||||
},
|
||||
_ => continue,
|
||||
};
|
||||
sink.extend(value.as_str().split_whitespace().map(|p| p.to_string()));
|
||||
}
|
||||
|
||||
if attr.is_word() && name == Some("document_private_items") {
|
||||
if default_passes == passes::DefaultPassOption::Default {
|
||||
default_passes = passes::DefaultPassOption::Private;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut passes: Vec<String> =
|
||||
passes::defaults(default_passes).iter().map(|p| p.to_string()).collect();
|
||||
passes.extend(manual_passes);
|
||||
|
||||
if !plugins.is_empty() {
|
||||
eprintln!("WARNING: --plugins no longer functions; see CVE-2018-1000622");
|
||||
}
|
||||
|
@ -752,7 +698,7 @@ where R: 'static + Send,
|
|||
|
||||
for pass in &passes {
|
||||
// determine if we know about this pass
|
||||
let pass = match passes::PASSES.iter().find(|p| p.name() == pass) {
|
||||
let pass = match passes::find_pass(pass) {
|
||||
Some(pass) => if let Some(pass) = pass.late_fn() {
|
||||
pass
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue