From 14dde99627119f76fd9970dcd07f883be5bc7101 Mon Sep 17 00:00:00 2001 From: Christophe MASSOLIN Date: Tue, 5 May 2020 18:15:13 +0200 Subject: Pass cargo.target to rustc --- crates/ra_project_model/src/lib.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'crates/ra_project_model') diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 731cbd291..8fa895aa6 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs @@ -543,7 +543,7 @@ impl ProjectWorkspace { } } -pub fn get_rustc_cfg_options() -> CfgOptions { +pub fn get_rustc_cfg_options(target: Option<&String>) -> CfgOptions { let mut cfg_options = CfgOptions::default(); // Some nightly-only cfgs, which are required for stdlib @@ -558,10 +558,18 @@ pub fn get_rustc_cfg_options() -> CfgOptions { match (|| -> Result { // `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here. - let output = Command::new("rustc") - .args(&["--print", "cfg", "-O"]) - .output() - .context("Failed to get output from rustc --print cfg -O")?; + let output = if let Some(target) = target { + Command::new("rustc") + .args(&["--print", "cfg", "-O", "--target", target.as_str()]) + .output() + .context("Failed to get output from rustc --print cfg -O")? + } else { + Command::new("rustc") + .args(&["--print", "cfg", "-O"]) + .output() + .context("Failed to get output from rustc --print cfg -O")? + }; + if !output.status.success() { bail!( "rustc --print cfg -O exited with exit code ({})", -- cgit v1.2.3