Skip to content

Commit 994144f

Browse files
committed
changed target from option to plain target, populated with host triple at argument parsing time if no --target arguments
1 parent 81df4a6 commit 994144f

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

Diff for: src/librustdoc/config.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc::lint::Level;
99
use rustc::session::early_error;
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;
@@ -46,7 +46,7 @@ pub struct Options {
4646
/// Debugging (`-Z`) options to pass to the compiler.
4747
pub debugging_options: DebuggingOptions,
4848
/// The target used to compile the crate against.
49-
pub target: Option<TargetTriple>,
49+
pub target: TargetTriple,
5050
/// Edition used when reading the crate. Defaults to "2015". Also used by default when
5151
/// compiling doctests from the crate.
5252
pub edition: Edition,
@@ -446,7 +446,9 @@ impl Options {
446446
}
447447
}
448448

449-
let target = matches.opt_str("target").map(|target| {
449+
let target = matches.opt_str("target").map_or(
450+
TargetTriple::from_triple(host_triple()),
451+
|target| {
450452
if target.ends_with(".json") {
451453
TargetTriple::TargetPath(PathBuf::from(target))
452454
} else {

Diff for: src/librustdoc/core.rs

+1-3
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::feature_gate::UnstableFeatures;
@@ -299,7 +298,6 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
299298
}
300299
}).collect();
301300

302-
let host_triple = TargetTriple::from_triple(config::host_triple());
303301
// plays with error output here!
304302
let sessopts = config::Options {
305303
maybe_sysroot,
@@ -313,7 +311,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
313311
lint_cap: Some(lint_cap.unwrap_or_else(|| lint::Forbid)),
314312
cg: codegen_options,
315313
externs,
316-
target_triple: target.unwrap_or(host_triple),
314+
target_triple: target,
317315
// Ensure that rustdoc works even if rustc is feature-staged
318316
unstable_features: UnstableFeatures::Allow,
319317
actually_rustdoc: true,

Diff for: src/librustdoc/test.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct TestOptions {
4444
pub fn run(options: Options) -> i32 {
4545
let input = config::Input::File(options.input.clone());
4646

47-
let mut sessopts = config::Options {
47+
let sessopts = config::Options {
4848
maybe_sysroot: options.maybe_sysroot.clone().or_else(
4949
|| Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
5050
search_paths: options.libs.clone(),
@@ -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()),
@@ -198,7 +197,7 @@ fn run_test(
198197
as_test_harness: bool,
199198
runtool: Option<String>,
200199
runtool_args: Vec<String>,
201-
target: Option<TargetTriple>,
200+
target: TargetTriple,
202201
compile_fail: bool,
203202
mut error_codes: Vec<String>,
204203
opts: &TestOptions,
@@ -244,7 +243,7 @@ fn run_test(
244243
..cg
245244
},
246245
test: as_test_harness,
247-
target_triple: target.unwrap_or(TargetTriple::from_triple(config::host_triple())),
246+
target_triple: target,
248247
unstable_features: UnstableFeatures::from_environment(),
249248
debugging_opts: config::DebuggingOptions {
250249
..config::basic_debugging_options()
@@ -686,7 +685,7 @@ pub struct Collector {
686685
persist_doctests: Option<PathBuf>,
687686
runtool: Option<String>,
688687
runtool_args: Vec<String>,
689-
target: Option<TargetTriple>,
688+
target: TargetTriple,
690689
pub enable_per_target_ignores: bool,
691690
}
692691

@@ -696,7 +695,7 @@ impl Collector {
696695
maybe_sysroot: Option<PathBuf>, source_map: Option<Lrc<SourceMap>>,
697696
filename: Option<PathBuf>, linker: Option<PathBuf>, edition: Edition,
698697
persist_doctests: Option<PathBuf>, runtool: Option<String>,
699-
runtool_args: Vec<String>, target: Option<TargetTriple>,
698+
runtool_args: Vec<String>, target: TargetTriple,
700699
enable_per_target_ignores: bool) -> Collector {
701700
Collector {
702701
tests: Vec::new(),
@@ -766,7 +765,7 @@ impl Tester for Collector {
766765
let runtool = self.runtool.clone();
767766
let runtool_args = self.runtool_args.clone();
768767
let target = self.target.clone();
769-
let target_str = target.as_ref().map(|t| t.to_string());
768+
let target_str = target.to_string();
770769

771770
debug!("Creating test {}: {}", name, test);
772771
self.tests.push(testing::TestDescAndFn {
@@ -776,8 +775,7 @@ impl Tester for Collector {
776775
Ignore::All => true,
777776
Ignore::None => false,
778777
Ignore::Some(ref ignores) => {
779-
target_str.map_or(false,
780-
|s| ignores.iter().any(|t| s.contains(t)))
778+
ignores.iter().any(|s| target_str.contains(s))
781779
},
782780
},
783781
// compiler failures are test failures

0 commit comments

Comments
 (0)