1 use std::collections::BTreeMap;
2 use std::convert::TryFrom;
5 use std::path::PathBuf;
8 use rustc_data_structures::fx::FxHashMap;
9 use rustc_session::config::{
10 self, parse_crate_types_from_list, parse_externs, parse_target_triple, CrateType,
12 use rustc_session::config::{get_cmd_lint_options, nightly_options};
13 use rustc_session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, Externs};
14 use rustc_session::getopts;
15 use rustc_session::lint::Level;
16 use rustc_session::search_paths::SearchPath;
17 use rustc_span::edition::Edition;
18 use rustc_target::spec::TargetTriple;
20 use crate::core::new_handler;
21 use crate::externalfiles::ExternalHtml;
23 use crate::html::markdown::IdMap;
24 use crate::html::render::StylePath;
25 use crate::html::static_files;
27 use crate::passes::{self, Condition, DefaultPassOption};
28 use crate::scrape_examples::AllCallLocations;
31 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
32 crate enum OutputFormat {
37 impl Default for OutputFormat {
38 fn default() -> OutputFormat {
44 crate fn is_json(&self) -> bool {
45 matches!(self, OutputFormat::Json)
49 impl TryFrom<&str> for OutputFormat {
52 fn try_from(value: &str) -> Result<Self, Self::Error> {
54 "json" => Ok(OutputFormat::Json),
55 "html" => Ok(OutputFormat::Html),
56 _ => Err(format!("unknown output format `{}`", value)),
61 /// Configuration options for rustdoc.
63 crate struct Options {
64 // Basic options / Options passed directly to rustc
65 /// The crate root or Markdown file to load.
67 /// The name of the crate being documented.
68 crate crate_name: Option<String>,
69 /// Whether or not this is a proc-macro crate
70 crate proc_macro_crate: bool,
71 /// How to format errors and warnings.
72 crate error_format: ErrorOutputType,
73 /// Library search paths to hand to the compiler.
74 crate libs: Vec<SearchPath>,
75 /// Library search paths strings to hand to the compiler.
76 crate lib_strs: Vec<String>,
77 /// The list of external crates to link against.
78 crate externs: Externs,
79 /// The list of external crates strings to link against.
80 crate extern_strs: Vec<String>,
81 /// List of `cfg` flags to hand to the compiler. Always includes `rustdoc`.
82 crate cfgs: Vec<String>,
83 /// Codegen options to hand to the compiler.
84 crate codegen_options: CodegenOptions,
85 /// Codegen options strings to hand to the compiler.
86 crate codegen_options_strs: Vec<String>,
87 /// Debugging (`-Z`) options to pass to the compiler.
88 crate debugging_opts: DebuggingOptions,
89 /// Debugging (`-Z`) options strings to pass to the compiler.
90 crate debugging_opts_strs: Vec<String>,
91 /// The target used to compile the crate against.
92 crate target: TargetTriple,
93 /// Edition used when reading the crate. Defaults to "2015". Also used by default when
94 /// compiling doctests from the crate.
95 crate edition: Edition,
96 /// The path to the sysroot. Used during the compilation process.
97 crate maybe_sysroot: Option<PathBuf>,
98 /// Lint information passed over the command-line.
99 crate lint_opts: Vec<(String, Level)>,
100 /// Whether to ask rustc to describe the lints it knows.
101 crate describe_lints: bool,
102 /// What level to cap lints at.
103 crate lint_cap: Option<Level>,
105 // Options specific to running doctests
106 /// Whether we should run doctests instead of generating docs.
107 crate should_test: bool,
108 /// List of arguments to pass to the test harness, if running tests.
109 crate test_args: Vec<String>,
110 /// The working directory in which to run tests.
111 crate test_run_directory: Option<PathBuf>,
112 /// Optional path to persist the doctest executables to, defaults to a
113 /// temporary directory if not set.
114 crate persist_doctests: Option<PathBuf>,
115 /// Runtool to run doctests with
116 crate runtool: Option<String>,
117 /// Arguments to pass to the runtool
118 crate runtool_args: Vec<String>,
119 /// Whether to allow ignoring doctests on a per-target basis
120 /// For example, using ignore-foo to ignore running the doctest on any target that
121 /// contains "foo" as a substring
122 crate enable_per_target_ignores: bool,
123 /// Do not run doctests, compile them if should_test is active.
126 /// The path to a rustc-like binary to build tests with. If not set, we
127 /// default to loading from `$sysroot/bin/rustc`.
128 crate test_builder: Option<PathBuf>,
130 // Options that affect the documentation process
131 /// The selected default set of passes to use.
133 /// Be aware: This option can come both from the CLI and from crate attributes!
134 crate default_passes: DefaultPassOption,
135 /// Any passes manually selected by the user.
137 /// Be aware: This option can come both from the CLI and from crate attributes!
138 crate manual_passes: Vec<String>,
139 /// Whether to display warnings during doc generation or while gathering doctests. By default,
140 /// all non-rustdoc-specific lints are allowed when generating docs.
141 crate display_doctest_warnings: bool,
142 /// Whether to run the `calculate-doc-coverage` pass, which counts the number of public items
143 /// with and without documentation.
144 crate show_coverage: bool,
146 // Options that alter generated documentation pages
147 /// Crate version to note on the sidebar of generated docs.
148 crate crate_version: Option<String>,
149 /// Collected options specific to outputting final pages.
150 crate render_options: RenderOptions,
151 /// The format that we output when rendering.
153 /// Currently used only for the `--show-coverage` option.
154 crate output_format: OutputFormat,
155 /// If this option is set to `true`, rustdoc will only run checks and not generate
157 crate run_check: bool,
158 /// Whether doctests should emit unused externs
159 crate json_unused_externs: bool,
160 /// Whether to skip capturing stdout and stderr of tests.
161 crate nocapture: bool,
163 /// Path to output file to write JSON of call sites. If this option is Some(..) then
164 /// the compiler will scrape examples and not generate documentation.
165 crate scrape_examples: Option<PathBuf>,
168 impl fmt::Debug for Options {
169 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
170 struct FmtExterns<'a>(&'a Externs);
172 impl<'a> fmt::Debug for FmtExterns<'a> {
173 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
174 f.debug_map().entries(self.0.iter()).finish()
178 f.debug_struct("Options")
179 .field("input", &self.input)
180 .field("crate_name", &self.crate_name)
181 .field("proc_macro_crate", &self.proc_macro_crate)
182 .field("error_format", &self.error_format)
183 .field("libs", &self.libs)
184 .field("externs", &FmtExterns(&self.externs))
185 .field("cfgs", &self.cfgs)
186 .field("codegen_options", &"...")
187 .field("debugging_options", &"...")
188 .field("target", &self.target)
189 .field("edition", &self.edition)
190 .field("maybe_sysroot", &self.maybe_sysroot)
191 .field("lint_opts", &self.lint_opts)
192 .field("describe_lints", &self.describe_lints)
193 .field("lint_cap", &self.lint_cap)
194 .field("should_test", &self.should_test)
195 .field("test_args", &self.test_args)
196 .field("test_run_directory", &self.test_run_directory)
197 .field("persist_doctests", &self.persist_doctests)
198 .field("default_passes", &self.default_passes)
199 .field("manual_passes", &self.manual_passes)
200 .field("display_doctest_warnings", &self.display_doctest_warnings)
201 .field("show_coverage", &self.show_coverage)
202 .field("crate_version", &self.crate_version)
203 .field("render_options", &self.render_options)
204 .field("runtool", &self.runtool)
205 .field("runtool_args", &self.runtool_args)
206 .field("enable-per-target-ignores", &self.enable_per_target_ignores)
207 .field("run_check", &self.run_check)
208 .field("no_run", &self.no_run)
209 .field("nocapture", &self.nocapture)
214 /// Configuration options for the HTML page-creation process.
215 #[derive(Clone, Debug)]
216 crate struct RenderOptions {
217 /// Output directory to generate docs into. Defaults to `doc`.
218 crate output: PathBuf,
219 /// External files to insert into generated pages.
220 crate external_html: ExternalHtml,
221 /// A pre-populated `IdMap` with the default headings and any headings added by Markdown files
222 /// processed by `external_html`.
224 /// If present, playground URL to use in the "Run" button added to code samples.
226 /// Be aware: This option can come both from the CLI and from crate attributes!
227 crate playground_url: Option<String>,
228 /// Whether to sort modules alphabetically on a module page instead of using declaration order.
229 /// `true` by default.
231 // FIXME(misdreavus): the flag name is `--sort-modules-by-appearance` but the meaning is
232 // inverted once read.
233 crate sort_modules_alphabetically: bool,
234 /// List of themes to extend the docs with. Original argument name is included to assist in
235 /// displaying errors if it fails a theme check.
236 crate themes: Vec<StylePath>,
237 /// If present, CSS file that contains rules to add to the default CSS.
238 crate extension_css: Option<PathBuf>,
239 /// A map of crate names to the URL to use instead of querying the crate's `html_root_url`.
240 crate extern_html_root_urls: BTreeMap<String, String>,
241 /// Whether to give precedence to `html_root_url` or `--exten-html-root-url`.
242 crate extern_html_root_takes_precedence: bool,
243 /// A map of the default settings (values are as for DOM storage API). Keys should lack the
244 /// `rustdoc-` prefix.
245 crate default_settings: FxHashMap<String, String>,
246 /// If present, suffix added to CSS/JavaScript files when referencing them in generated pages.
247 crate resource_suffix: String,
248 /// Whether to run the static CSS/JavaScript through a minifier when outputting them. `true` by
251 // FIXME(misdreavus): the flag name is `--disable-minification` but the meaning is inverted
253 crate enable_minification: bool,
254 /// Whether to create an index page in the root of the output directory. If this is true but
255 /// `enable_index_page` is None, generate a static listing of crates instead.
256 crate enable_index_page: bool,
257 /// A file to use as the index page at the root of the output directory. Overrides
258 /// `enable_index_page` to be true if set.
259 crate index_page: Option<PathBuf>,
260 /// An optional path to use as the location of static files. If not set, uses combinations of
261 /// `../` to reach the documentation root.
262 crate static_root_path: Option<String>,
264 // Options specific to reading standalone Markdown files
265 /// Whether to generate a table of contents on the output file when reading a standalone
267 crate markdown_no_toc: bool,
268 /// Additional CSS files to link in pages generated from standalone Markdown files.
269 crate markdown_css: Vec<String>,
270 /// If present, playground URL to use in the "Run" button added to code samples generated from
271 /// standalone Markdown files. If not present, `playground_url` is used.
272 crate markdown_playground_url: Option<String>,
273 /// If false, the `select` element to have search filtering by crates on rendered docs
274 /// won't be generated.
275 crate generate_search_filter: bool,
276 /// Document items that have lower than `pub` visibility.
277 crate document_private: bool,
278 /// Document items that have `doc(hidden)`.
279 crate document_hidden: bool,
280 /// If `true`, generate a JSON file in the crate folder instead of HTML redirection files.
281 crate generate_redirect_map: bool,
282 /// Show the memory layout of types in the docs.
283 crate show_type_layout: bool,
284 crate unstable_features: rustc_feature::UnstableFeatures,
285 crate emit: Vec<EmitType>,
286 /// If `true`, HTML source pages will generate links for items to their definition.
287 crate generate_link_to_definition: bool,
288 crate call_locations: Option<AllCallLocations>,
291 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
292 crate enum EmitType {
298 impl FromStr for EmitType {
301 fn from_str(s: &str) -> Result<Self, Self::Err> {
304 "unversioned-shared-resources" => Ok(Unversioned),
305 "toolchain-shared-resources" => Ok(Toolchain),
306 "invocation-specific" => Ok(InvocationSpecific),
313 crate fn should_emit_crate(&self) -> bool {
314 self.emit.is_empty() || self.emit.contains(&EmitType::InvocationSpecific)
319 /// Parses the given command-line for options. If an error message or other early-return has
320 /// been printed, returns `Err` with the exit code.
321 crate fn from_matches(matches: &getopts::Matches) -> Result<Options, i32> {
322 // Check for unstable options.
323 nightly_options::check_nightly_options(&matches, &opts());
325 if matches.opt_present("h") || matches.opt_present("help") {
326 crate::usage("rustdoc");
328 } else if matches.opt_present("version") {
329 rustc_driver::version("rustdoc", &matches);
333 if matches.opt_strs("passes") == ["list"] {
334 println!("Available passes for running rustdoc:");
335 for pass in passes::PASSES {
336 println!("{:>20} - {}", pass.name, pass.description);
338 println!("\nDefault passes for rustdoc:");
339 for p in passes::DEFAULT_PASSES {
340 print!("{:>20}", p.pass.name);
341 println_condition(p.condition);
344 if nightly_options::match_is_nightly_build(matches) {
345 println!("\nPasses run with `--show-coverage`:");
346 for p in passes::COVERAGE_PASSES {
347 print!("{:>20}", p.pass.name);
348 println_condition(p.condition);
352 fn println_condition(condition: Condition) {
355 Always => println!(),
356 WhenDocumentPrivate => println!(" (when --document-private-items)"),
357 WhenNotDocumentPrivate => println!(" (when not --document-private-items)"),
358 WhenNotDocumentHidden => println!(" (when not --document-hidden-items)"),
365 let color = config::parse_color(&matches);
366 let config::JsonConfig { json_rendered, json_unused_externs, .. } =
367 config::parse_json(&matches);
368 let error_format = config::parse_error_format(&matches, color, json_rendered);
370 let codegen_options = CodegenOptions::build(matches, error_format);
371 let debugging_opts = DebuggingOptions::build(matches, error_format);
373 let diag = new_handler(error_format, None, &debugging_opts);
375 // check for deprecated options
376 check_deprecated_options(&matches, &diag);
378 let mut emit = Vec::new();
379 for list in matches.opt_strs("emit") {
380 for kind in list.split(',') {
382 Ok(kind) => emit.push(kind),
384 diag.err(&format!("unrecognized emission type: {}", kind));
391 // check for `--output-format=json`
392 if !matches!(matches.opt_str("output-format").as_deref(), None | Some("html"))
393 && !matches.opt_present("show-coverage")
394 && !nightly_options::is_unstable_enabled(matches)
396 rustc_session::early_error(
398 "the -Z unstable-options flag must be passed to enable --output-format for documentation generation (see https://github.com/rust-lang/rust/issues/76578)",
402 let to_check = matches.opt_strs("check-theme");
403 if !to_check.is_empty() {
404 let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes());
407 println!("rustdoc: [check-theme] Starting tests! (Ignoring all other arguments)");
408 for theme_file in to_check.iter() {
409 print!(" - Checking \"{}\"...", theme_file);
410 let (success, differences) = theme::test_theme_against(theme_file, &paths, &diag);
411 if !differences.is_empty() || !success {
414 if !differences.is_empty() {
415 println!("{}", differences.join("\n"));
427 if matches.free.is_empty() {
428 diag.struct_err("missing file operand").emit();
431 if matches.free.len() > 1 {
432 diag.struct_err("too many file operands").emit();
435 let input = PathBuf::from(&matches.free[0]);
440 .map(|s| SearchPath::from_cli_opt(s, error_format))
442 let externs = parse_externs(&matches, &debugging_opts, error_format);
443 let extern_html_root_urls = match parse_extern_html_roots(&matches) {
446 diag.struct_err(err).emit();
451 let default_settings: Vec<Vec<(String, String)>> = vec![
453 .opt_str("default-theme")
457 ("use-system-theme".to_string(), "false".to_string()),
458 ("theme".to_string(), theme.to_string()),
464 .opt_strs("default-setting")
466 .map(|s| match s.split_once('=') {
467 None => (s.clone(), "true".to_string()),
468 Some((k, v)) => (k.to_string(), v.to_string()),
472 let default_settings = default_settings
476 // The keys here become part of `data-` attribute names in the generated HTML. The
477 // browser does a strange mapping when converting them into attributes on the
478 // `dataset` property on the DOM HTML Node:
479 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
481 // The original key values we have are the same as the DOM storage API keys and the
482 // command line options, so contain `-`. Our Javascript needs to be able to look
483 // these values up both in `dataset` and in the storage API, so it needs to be able
484 // to convert the names back and forth. Despite doing this kebab-case to
485 // StudlyCaps transformation automatically, the JS DOM API does not provide a
486 // mechanism for doing the just transformation on a string. So we want to avoid
487 // the StudlyCaps representation in the `dataset` property.
489 // We solve this by replacing all the `-`s with `_`s. We do that here, when we
490 // generate the `data-` attributes, and in the JS, when we look them up. (See
491 // `getSettingValue` in `storage.js.`) Converting `-` to `_` is simple in JS.
493 // The values will be HTML-escaped by the default Tera escaping.
494 |(k, v)| (k.replace('-', "_"), v),
498 let test_args = matches.opt_strs("test-args");
499 let test_args: Vec<String> =
500 test_args.iter().flat_map(|s| s.split_whitespace()).map(|s| s.to_string()).collect();
502 let should_test = matches.opt_present("test");
503 let no_run = matches.opt_present("no-run");
505 if !should_test && no_run {
506 diag.err("the `--test` flag must be passed to enable `--no-run`");
511 matches.opt_str("o").map(|s| PathBuf::from(&s)).unwrap_or_else(|| PathBuf::from("doc"));
512 let cfgs = matches.opt_strs("cfg");
514 let extension_css = matches.opt_str("e").map(|s| PathBuf::from(&s));
516 if let Some(ref p) = extension_css {
518 diag.struct_err("option --extend-css argument must be a file").emit();
523 let mut themes = Vec::new();
524 if matches.opt_present("theme") {
525 let paths = theme::load_css_paths(static_files::themes::LIGHT.as_bytes());
527 for (theme_file, theme_s) in
528 matches.opt_strs("theme").iter().map(|s| (PathBuf::from(&s), s.to_owned()))
530 if !theme_file.is_file() {
531 diag.struct_err(&format!("invalid argument: \"{}\"", theme_s))
532 .help("arguments to --theme must be files")
536 if theme_file.extension() != Some(OsStr::new("css")) {
537 diag.struct_err(&format!("invalid argument: \"{}\"", theme_s))
538 .help("arguments to --theme must have a .css extension")
542 let (success, ret) = theme::test_theme_against(&theme_file, &paths, &diag);
544 diag.struct_err(&format!("error loading theme file: \"{}\"", theme_s)).emit();
546 } else if !ret.is_empty() {
547 diag.struct_warn(&format!(
548 "theme file \"{}\" is missing CSS rules from the default theme",
551 .warn("the theme may appear incorrect when loaded")
553 "to see what rules are missing, call `rustdoc --check-theme \"{}\"`",
558 themes.push(StylePath { path: theme_file, disabled: true });
562 let edition = config::parse_crate_edition(&matches);
564 let mut id_map = html::markdown::IdMap::new();
565 let external_html = match ExternalHtml::load(
566 &matches.opt_strs("html-in-header"),
567 &matches.opt_strs("html-before-content"),
568 &matches.opt_strs("html-after-content"),
569 &matches.opt_strs("markdown-before-content"),
570 &matches.opt_strs("markdown-after-content"),
571 nightly_options::match_is_nightly_build(&matches),
578 None => return Err(3),
581 match matches.opt_str("r").as_deref() {
582 Some("rust") | None => {}
584 diag.struct_err(&format!("unknown input format: {}", s)).emit();
589 let index_page = matches.opt_str("index-page").map(|s| PathBuf::from(&s));
590 if let Some(ref index_page) = index_page {
591 if !index_page.is_file() {
592 diag.struct_err("option `--index-page` argument must be a file").emit();
597 let target = parse_target_triple(matches, error_format);
599 let show_coverage = matches.opt_present("show-coverage");
601 let default_passes = if matches.opt_present("no-defaults") {
602 passes::DefaultPassOption::None
603 } else if show_coverage {
604 passes::DefaultPassOption::Coverage
606 passes::DefaultPassOption::Default
608 let manual_passes = matches.opt_strs("passes");
610 let crate_types = match parse_crate_types_from_list(matches.opt_strs("crate-type")) {
613 diag.struct_err(&format!("unknown crate type: {}", e)).emit();
618 let output_format = match matches.opt_str("output-format") {
619 Some(s) => match OutputFormat::try_from(s.as_str()) {
621 if !out_fmt.is_json() && show_coverage {
623 "html output format isn't supported for the --show-coverage option",
631 diag.struct_err(&e).emit();
635 None => OutputFormat::default(),
637 let crate_name = matches.opt_str("crate-name");
638 let proc_macro_crate = crate_types.contains(&CrateType::ProcMacro);
639 let playground_url = matches.opt_str("playground-url");
640 let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
641 let display_doctest_warnings = matches.opt_present("display-doctest-warnings");
642 let sort_modules_alphabetically = !matches.opt_present("sort-modules-by-appearance");
643 let resource_suffix = matches.opt_str("resource-suffix").unwrap_or_default();
644 let enable_minification = !matches.opt_present("disable-minification");
645 let markdown_no_toc = matches.opt_present("markdown-no-toc");
646 let markdown_css = matches.opt_strs("markdown-css");
647 let markdown_playground_url = matches.opt_str("markdown-playground-url");
648 let crate_version = matches.opt_str("crate-version");
649 let enable_index_page = matches.opt_present("enable-index-page") || index_page.is_some();
650 let static_root_path = matches.opt_str("static-root-path");
651 let generate_search_filter = !matches.opt_present("disable-per-crate-search");
652 let test_run_directory = matches.opt_str("test-run-directory").map(PathBuf::from);
653 let persist_doctests = matches.opt_str("persist-doctests").map(PathBuf::from);
654 let test_builder = matches.opt_str("test-builder").map(PathBuf::from);
655 let codegen_options_strs = matches.opt_strs("C");
656 let debugging_opts_strs = matches.opt_strs("Z");
657 let lib_strs = matches.opt_strs("L");
658 let extern_strs = matches.opt_strs("extern");
659 let runtool = matches.opt_str("runtool");
660 let runtool_args = matches.opt_strs("runtool-arg");
661 let enable_per_target_ignores = matches.opt_present("enable-per-target-ignores");
662 let document_private = matches.opt_present("document-private-items");
663 let document_hidden = matches.opt_present("document-hidden-items");
664 let run_check = matches.opt_present("check");
665 let generate_redirect_map = matches.opt_present("generate-redirect-map");
666 let show_type_layout = matches.opt_present("show-type-layout");
667 let nocapture = matches.opt_present("nocapture");
668 let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
669 let extern_html_root_takes_precedence =
670 matches.opt_present("extern-html-root-takes-precedence");
672 if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
674 "--generate-link-to-definition option can only be used with HTML output format",
680 let scrape_examples = matches.opt_str("scrape-examples").map(PathBuf::from);
681 let with_examples = matches.opt_strs("with-examples");
682 let call_locations = crate::scrape_examples::load_call_locations(with_examples, &diag)?;
684 let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
696 codegen_options_strs,
709 display_doctest_warnings,
716 enable_per_target_ignores,
721 render_options: RenderOptions {
726 sort_modules_alphabetically,
729 extern_html_root_urls,
730 extern_html_root_takes_precedence,
739 markdown_playground_url,
740 generate_search_filter,
743 generate_redirect_map,
745 unstable_features: rustc_feature::UnstableFeatures::from_environment(
746 crate_name.as_deref(),
749 generate_link_to_definition,
759 /// Returns `true` if the file given as `self.input` is a Markdown file.
760 crate fn markdown_input(&self) -> bool {
761 self.input.extension().map_or(false, |e| e == "md" || e == "markdown")
765 /// Prints deprecation warnings for deprecated options
766 fn check_deprecated_options(matches: &getopts::Matches, diag: &rustc_errors::Handler) {
767 let deprecated_flags = ["input-format", "no-defaults", "passes"];
769 for flag in deprecated_flags.iter() {
770 if matches.opt_present(flag) {
771 let mut err = diag.struct_warn(&format!("the `{}` flag is deprecated", flag));
773 "see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \
774 for more information",
777 if *flag == "no-defaults" {
778 err.help("you may want to use --document-private-items");
785 let removed_flags = ["plugins", "plugin-path"];
787 for &flag in removed_flags.iter() {
788 if matches.opt_present(flag) {
789 diag.struct_warn(&format!("the '{}' flag no longer functions", flag))
790 .warn("see CVE-2018-1000622")
796 /// Extracts `--extern-html-root-url` arguments from `matches` and returns a map of crate names to
797 /// the given URLs. If an `--extern-html-root-url` argument was ill-formed, returns an error
798 /// describing the issue.
799 fn parse_extern_html_roots(
800 matches: &getopts::Matches,
801 ) -> Result<BTreeMap<String, String>, &'static str> {
802 let mut externs = BTreeMap::new();
803 for arg in &matches.opt_strs("extern-html-root-url") {
805 arg.split_once('=').ok_or("--extern-html-root-url must be of the form name=url")?;
806 externs.insert(name.to_string(), url.to_string());