Use parse_target_triple in rustdoc

This commit is contained in:
bjorn3 2021-05-16 15:35:10 +02:00
parent 8260b8325c
commit f22a80890a
2 changed files with 9 additions and 11 deletions

View File

@ -1507,7 +1507,10 @@ fn collect_print_requests(
prints
}
fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType) -> TargetTriple {
pub fn parse_target_triple(
matches: &getopts::Matches,
error_format: ErrorOutputType,
) -> TargetTriple {
match matches.opt_str("target") {
Some(target) if target.ends_with(".json") => {
let path = Path::new(&target);

View File

@ -6,8 +6,10 @@ use std::path::PathBuf;
use std::str::FromStr;
use rustc_data_structures::fx::FxHashMap;
use rustc_session::config::{self, parse_crate_types_from_list, parse_externs, CrateType};
use rustc_session::config::{get_cmd_lint_options, host_triple, nightly_options};
use rustc_session::config::{
self, parse_crate_types_from_list, parse_externs, parse_target_triple, CrateType,
};
use rustc_session::config::{get_cmd_lint_options, nightly_options};
use rustc_session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, Externs};
use rustc_session::getopts;
use rustc_session::lint::Level;
@ -562,14 +564,7 @@ impl Options {
}
}
let target =
matches.opt_str("target").map_or(TargetTriple::from_triple(host_triple()), |target| {
if target.ends_with(".json") {
TargetTriple::from_path(Path::new(&target))
} else {
TargetTriple::TargetTriple(target)
}
});
let target = parse_target_triple(matches, error_format);
let show_coverage = matches.opt_present("show-coverage");