Skip to content

Commit 657e24c

Browse files
committed
changed target from option to plain target, populated with host triple at argument parsing time if no --target arguments
1 parent 3f76408 commit 657e24c

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/librustdoc/config.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc::session;
99
use rustc::session::config::{CrateType, parse_crate_types_from_list};
1010
use rustc::session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, Externs};
1111
use rustc::session::config::{nightly_options, build_codegen_options, build_debugging_options,
12-
get_cmd_lint_options, ExternEntry};
12+
get_cmd_lint_options, host_triple, ExternEntry};
1313
use rustc::session::search_paths::SearchPath;
1414
use rustc_driver;
1515
use rustc_target::spec::TargetTriple;
@@ -54,7 +54,7 @@ pub struct Options {
5454
/// Debugging (`-Z`) options to pass to the compiler.
5555
pub debugging_options: DebuggingOptions,
5656
/// The target used to compile the crate against.
57-
pub target: Option<TargetTriple>,
57+
pub target: TargetTriple,
5858
/// Edition used when reading the crate. Defaults to "2015". Also used by default when
5959
/// compiling doctests from the crate.
6060
pub edition: Edition,
@@ -425,7 +425,9 @@ impl Options {
425425
}
426426
}
427427

428-
let target = matches.opt_str("target").map(|target| {
428+
let target = matches.opt_str("target").map_or(
429+
TargetTriple::from_triple(host_triple()),
430+
|target| {
429431
if target.ends_with(".json") {
430432
TargetTriple::TargetPath(PathBuf::from(target))
431433
} else {

src/librustdoc/core.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_interface::interface;
1313
use rustc_driver::abort_on_err;
1414
use rustc_resolve as resolve;
1515
use rustc_metadata::cstore::CStore;
16-
use rustc_target::spec::TargetTriple;
1716

1817
use syntax::source_map;
1918
use syntax::attr;
@@ -313,7 +312,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
313312
lint_cap: Some(lint_cap.unwrap_or_else(|| lint::Forbid)),
314313
cg: codegen_options,
315314
externs,
316-
target_triple: target.unwrap_or(host_triple),
315+
target_triple: target,
317316
// Ensure that rustdoc works even if rustc is feature-staged
318317
unstable_features: UnstableFeatures::Allow,
319318
actually_rustdoc: true,

src/librustdoc/test.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ pub fn run(options: Options) -> i32 {
6060
edition: options.edition,
6161
..config::Options::default()
6262
};
63-
options.target.as_ref().map(|t| { sessopts.target_triple = t.clone() });
6463
let config = interface::Config {
6564
opts: sessopts,
6665
crate_cfg: config::parse_cfgspecs(options.cfgs.clone()),
@@ -184,7 +183,7 @@ fn run_test(
184183
as_test_harness: bool,
185184
runtool: Option<String>,
186185
runtool_args: Vec<String>,
187-
target: Option<TargetTriple>,
186+
target: TargetTriple,
188187
compile_fail: bool,
189188
mut error_codes: Vec<String>,
190189
opts: &TestOptions,
@@ -680,7 +679,7 @@ impl Tester for Collector {
680679
let runtool = self.runtool.clone();
681680
let runtool_args = self.runtool_args.clone();
682681
let target = self.target.clone();
683-
let target_str = target.as_ref().map(|t| t.to_string());
682+
let target_str = target.to_string();
684683

685684
debug!("creating test {}: {}", name, test);
686685
self.tests.push(testing::TestDescAndFn {
@@ -690,8 +689,7 @@ impl Tester for Collector {
690689
Ignore::All => true,
691690
Ignore::None => false,
692691
Ignore::Some(ref ignores) => {
693-
target_str.map_or(false,
694-
|s| ignores.iter().any(|t| s.contains(t)))
692+
ignores.iter().any(|s| target_str.contains(s))
695693
},
696694
},
697695
// compiler failures are test failures

0 commit comments

Comments
 (0)