aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_project_model/src/lib.rs18
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs2
-rw-r--r--crates/rust-analyzer/src/world.rs2
3 files changed, 15 insertions, 7 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 ({})",
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index d0a71120a..023ced6cf 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -149,7 +149,7 @@ pub(crate) fn load(
149 149
150 // FIXME: cfg options? 150 // FIXME: cfg options?
151 let default_cfg_options = { 151 let default_cfg_options = {
152 let mut opts = get_rustc_cfg_options(); 152 let mut opts = get_rustc_cfg_options(None);
153 opts.insert_atom("test".into()); 153 opts.insert_atom("test".into());
154 opts.insert_atom("debug_assertion".into()); 154 opts.insert_atom("debug_assertion".into());
155 opts 155 opts
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs
index 34941931b..16020648d 100644
--- a/crates/rust-analyzer/src/world.rs
+++ b/crates/rust-analyzer/src/world.rs
@@ -131,7 +131,7 @@ impl WorldState {
131 131
132 // FIXME: Read default cfgs from config 132 // FIXME: Read default cfgs from config
133 let default_cfg_options = { 133 let default_cfg_options = {
134 let mut opts = get_rustc_cfg_options(); 134 let mut opts = get_rustc_cfg_options(config.cargo.target.as_ref());
135 opts.insert_atom("test".into()); 135 opts.insert_atom("test".into());
136 opts.insert_atom("debug_assertion".into()); 136 opts.insert_atom("debug_assertion".into());
137 opts 137 opts