diff options
Diffstat (limited to 'src/librustdoc/config.rs')
| -rw-r--r-- | src/librustdoc/config.rs | 102 |
1 files changed, 50 insertions, 52 deletions
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 04bcade156a..d300afa3132 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -24,7 +24,7 @@ use crate::html::markdown::IdMap; use crate::html::render::StylePath; use crate::html::static_files; use crate::opts; -use crate::passes::{self, Condition, DefaultPassOption}; +use crate::passes::{self, Condition}; use crate::scrape_examples::{AllCallLocations, ScrapeExamplesOptions}; use crate::theme; @@ -128,14 +128,6 @@ crate struct Options { crate test_builder: Option<PathBuf>, // Options that affect the documentation process - /// The selected default set of passes to use. - /// - /// Be aware: This option can come both from the CLI and from crate attributes! - crate default_passes: DefaultPassOption, - /// Any passes manually selected by the user. - /// - /// Be aware: This option can come both from the CLI and from crate attributes! - crate manual_passes: Vec<String>, /// Whether to run the `calculate-doc-coverage` pass, which counts the number of public items /// with and without documentation. crate show_coverage: bool, @@ -192,8 +184,6 @@ impl fmt::Debug for Options { .field("test_args", &self.test_args) .field("test_run_directory", &self.test_run_directory) .field("persist_doctests", &self.persist_doctests) - .field("default_passes", &self.default_passes) - .field("manual_passes", &self.manual_passes) .field("show_coverage", &self.show_coverage) .field("crate_version", &self.crate_version) .field("render_options", &self.render_options) @@ -282,7 +272,10 @@ crate struct RenderOptions { crate emit: Vec<EmitType>, /// If `true`, HTML source pages will generate links for items to their definition. crate generate_link_to_definition: bool, + /// Set of function-call locations to include as examples crate call_locations: AllCallLocations, + /// If `true`, Context::init will not emit shared files. + crate no_emit_shared: bool, } #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -327,6 +320,19 @@ impl Options { return Err(0); } + let color = config::parse_color(matches); + let config::JsonConfig { json_rendered, json_unused_externs, .. } = + config::parse_json(matches); + let error_format = config::parse_error_format(matches, color, json_rendered); + + let codegen_options = CodegenOptions::build(matches, error_format); + let debugging_opts = DebuggingOptions::build(matches, error_format); + + let diag = new_handler(error_format, None, &debugging_opts); + + // check for deprecated options + check_deprecated_options(matches, &diag); + if matches.opt_strs("passes") == ["list"] { println!("Available passes for running rustdoc:"); for pass in passes::PASSES { @@ -359,19 +365,6 @@ impl Options { return Err(0); } - let color = config::parse_color(matches); - let config::JsonConfig { json_rendered, json_unused_externs, .. } = - config::parse_json(matches); - let error_format = config::parse_error_format(matches, color, json_rendered); - - let codegen_options = CodegenOptions::build(matches, error_format); - let debugging_opts = DebuggingOptions::build(matches, error_format); - - let diag = new_handler(error_format, None, &debugging_opts); - - // check for deprecated options - check_deprecated_options(matches, &diag); - let mut emit = Vec::new(); for list in matches.opt_strs("emit") { for kind in list.split(',') { @@ -504,8 +497,18 @@ impl Options { return Err(1); } - let output = - matches.opt_str("o").map(|s| PathBuf::from(&s)).unwrap_or_else(|| PathBuf::from("doc")); + let out_dir = matches.opt_str("out-dir").map(|s| PathBuf::from(&s)); + let output = matches.opt_str("output").map(|s| PathBuf::from(&s)); + let output = match (out_dir, output) { + (Some(_), Some(_)) => { + diag.struct_err("cannot use both 'out-dir' and 'output' at once").emit(); + return Err(1); + } + (Some(out_dir), None) => out_dir, + (None, Some(output)) => output, + (None, None) => PathBuf::from("doc"), + }; + let cfgs = matches.opt_strs("cfg"); let extension_css = matches.opt_str("e").map(|s| PathBuf::from(&s)); @@ -595,15 +598,6 @@ impl Options { let show_coverage = matches.opt_present("show-coverage"); - let default_passes = if matches.opt_present("no-defaults") { - passes::DefaultPassOption::None - } else if show_coverage { - passes::DefaultPassOption::Coverage - } else { - passes::DefaultPassOption::Default - }; - let manual_passes = matches.opt_strs("passes"); - let crate_types = match parse_crate_types_from_list(matches.opt_strs("crate-type")) { Ok(types) => types, Err(e) => { @@ -700,8 +694,6 @@ impl Options { lint_cap, should_test, test_args, - default_passes, - manual_passes, show_coverage, crate_version, test_run_directory, @@ -743,6 +735,7 @@ impl Options { emit, generate_link_to_definition, call_locations, + no_emit_shared: false, }, crate_name, output_format, @@ -759,33 +752,38 @@ impl Options { /// Prints deprecation warnings for deprecated options fn check_deprecated_options(matches: &getopts::Matches, diag: &rustc_errors::Handler) { - let deprecated_flags = ["input-format", "no-defaults", "passes"]; + let deprecated_flags = []; - for flag in deprecated_flags.iter() { + for &flag in deprecated_flags.iter() { if matches.opt_present(flag) { - let mut err = diag.struct_warn(&format!("the `{}` flag is deprecated", flag)); + diag.struct_warn(&format!("the `{}` flag is deprecated", flag)) + .note( + "see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \ + for more information", + ) + .emit(); + } + } + + let removed_flags = ["plugins", "plugin-path", "no-defaults", "passes", "input-format"]; + + for &flag in removed_flags.iter() { + if matches.opt_present(flag) { + let mut err = diag.struct_warn(&format!("the `{}` flag no longer functions", flag)); err.note( "see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \ - for more information", + for more information", ); - if *flag == "no-defaults" { + if flag == "no-defaults" || flag == "passes" { err.help("you may want to use --document-private-items"); + } else if flag == "plugins" || flag == "plugin-path" { + err.warn("see CVE-2018-1000622"); } err.emit(); } } - - let removed_flags = ["plugins", "plugin-path"]; - - for &flag in removed_flags.iter() { - if matches.opt_present(flag) { - diag.struct_warn(&format!("the '{}' flag no longer functions", flag)) - .warn("see CVE-2018-1000622") - .emit(); - } - } } /// Extracts `--extern-html-root-url` arguments from `matches` and returns a map of crate names to |
