Rollup merge of #82261 - ojeda:rustdoc-argfile, r=jyn514

rustdoc: Support argument files

Factors out the `rustc_driver` logic that handles argument files so that rustdoc supports them as well, e.g.:

    rustdoc `@argfile`

This is needed to be able to generate docs for projects that already use argument files when compiling them, e.g. projects that pass a huge number of `--cfg` arguments.

The feature was stabilized for `rustc` in #66172.
This commit is contained in:
Dylan DPC
2021-02-19 02:49:12 +01:00
committed by GitHub
11 changed files with 77 additions and 13 deletions

View File

@@ -55,7 +55,7 @@ use std::process::{self, Command, Stdio};
use std::str;
use std::time::Instant;
mod args;
pub mod args;
pub mod pretty;
/// Exit status code used for successful compilation and help output.
@@ -188,16 +188,8 @@ fn run_compiler(
Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>,
>,
) -> interface::Result<()> {
let mut args = Vec::new();
for arg in at_args {
match args::arg_expand(arg.clone()) {
Ok(arg) => args.extend(arg),
Err(err) => early_error(
ErrorOutputType::default(),
&format!("Failed to load argument file: {}", err),
),
}
}
let args = args::arg_expand_all(at_args);
let diagnostic_output = emitter.map_or(DiagnosticOutput::Default, DiagnosticOutput::Raw);
let matches = match handle_options(&args) {
Some(matches) => matches,