Skip to content

Commit f22a808

Browse files
committed
Use parse_target_triple in rustdoc
1 parent 8260b83 commit f22a808

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,10 @@ fn collect_print_requests(
15071507
prints
15081508
}
15091509

1510-
fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType) -> TargetTriple {
1510+
pub fn parse_target_triple(
1511+
matches: &getopts::Matches,
1512+
error_format: ErrorOutputType,
1513+
) -> TargetTriple {
15111514
match matches.opt_str("target") {
15121515
Some(target) if target.ends_with(".json") => {
15131516
let path = Path::new(&target);

src/librustdoc/config.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ use std::path::PathBuf;
66
use std::str::FromStr;
77

88
use rustc_data_structures::fx::FxHashMap;
9-
use rustc_session::config::{self, parse_crate_types_from_list, parse_externs, CrateType};
10-
use rustc_session::config::{get_cmd_lint_options, host_triple, nightly_options};
9+
use rustc_session::config::{
10+
self, parse_crate_types_from_list, parse_externs, parse_target_triple, CrateType,
11+
};
12+
use rustc_session::config::{get_cmd_lint_options, nightly_options};
1113
use rustc_session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, Externs};
1214
use rustc_session::getopts;
1315
use rustc_session::lint::Level;
@@ -562,14 +564,7 @@ impl Options {
562564
}
563565
}
564566

565-
let target =
566-
matches.opt_str("target").map_or(TargetTriple::from_triple(host_triple()), |target| {
567-
if target.ends_with(".json") {
568-
TargetTriple::from_path(Path::new(&target))
569-
} else {
570-
TargetTriple::TargetTriple(target)
571-
}
572-
});
567+
let target = parse_target_triple(matches, error_format);
573568

574569
let show_coverage = matches.opt_present("show-coverage");
575570

0 commit comments

Comments
 (0)