aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs12
-rw-r--r--crates/rust-analyzer/src/config.rs1
2 files changed, 13 insertions, 0 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index 362ee30fe..810833b64 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -43,6 +43,11 @@ impl ops::Index<Target> for CargoWorkspace {
43} 43}
44 44
45#[derive(Clone, Debug, PartialEq, Eq)] 45#[derive(Clone, Debug, PartialEq, Eq)]
46pub struct RustcConfig {
47 pub default_target: Option<String>,
48}
49
50#[derive(Clone, Debug, PartialEq, Eq)]
46pub struct CargoConfig { 51pub struct CargoConfig {
47 /// Do not activate the `default` feature. 52 /// Do not activate the `default` feature.
48 pub no_default_features: bool, 53 pub no_default_features: bool,
@@ -56,6 +61,9 @@ pub struct CargoConfig {
56 61
57 /// Runs cargo check on launch to figure out the correct values of OUT_DIR 62 /// Runs cargo check on launch to figure out the correct values of OUT_DIR
58 pub load_out_dirs_from_check: bool, 63 pub load_out_dirs_from_check: bool,
64
65 /// rustc config
66 pub rustc: RustcConfig,
59} 67}
60 68
61impl Default for CargoConfig { 69impl Default for CargoConfig {
@@ -65,6 +73,7 @@ impl Default for CargoConfig {
65 all_features: true, 73 all_features: true,
66 features: Vec::new(), 74 features: Vec::new(),
67 load_out_dirs_from_check: false, 75 load_out_dirs_from_check: false,
76 rustc: RustcConfig { default_target: None },
68 } 77 }
69 } 78 }
70} 79}
@@ -160,6 +169,9 @@ impl CargoWorkspace {
160 if let Some(parent) = cargo_toml.parent() { 169 if let Some(parent) = cargo_toml.parent() {
161 meta.current_dir(parent); 170 meta.current_dir(parent);
162 } 171 }
172 if let Some(target) = cargo_features.rustc.default_target.as_ref() {
173 meta.other_options(&[String::from("--filter-platform"), target.clone()]);
174 }
163 let meta = meta.exec().with_context(|| { 175 let meta = meta.exec().with_context(|| {
164 format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display()) 176 format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display())
165 })?; 177 })?;
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 715eddadb..908208ece 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -134,6 +134,7 @@ impl Config {
134 set(value, "/cargo/allFeatures", &mut self.cargo.all_features); 134 set(value, "/cargo/allFeatures", &mut self.cargo.all_features);
135 set(value, "/cargo/features", &mut self.cargo.features); 135 set(value, "/cargo/features", &mut self.cargo.features);
136 set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); 136 set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check);
137 set(value, "/cargo/rustc/defaultTarget", &mut self.cargo.rustc.default_target);
137 138
138 match get(value, "/procMacro/enable") { 139 match get(value, "/procMacro/enable") {
139 Some(true) => { 140 Some(true) => {