aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src
diff options
context:
space:
mode:
authorChristophe MASSOLIN <[email protected]>2020-05-05 17:15:13 +0100
committerChristophe MASSOLIN <[email protected]>2020-05-05 17:15:13 +0100
commit14dde99627119f76fd9970dcd07f883be5bc7101 (patch)
tree687af617a53f8eb238d9251fc9ec8cdf1edb0e76 /crates/ra_project_model/src
parent0ab4340cdb31ac4d50f039f0a56ebaff86710eb7 (diff)
Pass cargo.target to rustc
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r--crates/ra_project_model/src/lib.rs18
1 files changed, 13 insertions, 5 deletions
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 {
543 } 543 }
544} 544}
545 545
546pub fn get_rustc_cfg_options() -> CfgOptions { 546pub fn get_rustc_cfg_options(target: Option<&String>) -> CfgOptions {
547 let mut cfg_options = CfgOptions::default(); 547 let mut cfg_options = CfgOptions::default();
548 548
549 // Some nightly-only cfgs, which are required for stdlib 549 // Some nightly-only cfgs, which are required for stdlib
@@ -558,10 +558,18 @@ pub fn get_rustc_cfg_options() -> CfgOptions {
558 558
559 match (|| -> Result<String> { 559 match (|| -> Result<String> {
560 // `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here. 560 // `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here.
561 let output = Command::new("rustc") 561 let output = if let Some(target) = target {
562 .args(&["--print", "cfg", "-O"]) 562 Command::new("rustc")
563 .output() 563 .args(&["--print", "cfg", "-O", "--target", target.as_str()])
564 .context("Failed to get output from rustc --print cfg -O")?; 564 .output()
565 .context("Failed to get output from rustc --print cfg -O")?
566 } else {
567 Command::new("rustc")
568 .args(&["--print", "cfg", "-O"])
569 .output()
570 .context("Failed to get output from rustc --print cfg -O")?
571 };
572
565 if !output.status.success() { 573 if !output.status.success() {
566 bail!( 574 bail!(
567 "rustc --print cfg -O exited with exit code ({})", 575 "rustc --print cfg -O exited with exit code ({})",