Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions rust/extractor/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,23 @@
figment.extract().context("loading configuration")
}

fn get_extra_env(&self) -> FxHashMap<String, Option<String>> {
let mut extra_env = FxHashMap::default();
// RUSTUP_AUTO_INSTALL is set to 0 by rust-analyzer (https://github.com/rust-lang/rust-analyzer/issues/20719),
// but we do want to allow rustup to auto-install toolchains if needed, so we set it to 1 here.
extra_env.insert("RUSTUP_AUTO_INSTALL".to_owned(), Some("1".to_owned()));
extra_env.extend(self.cargo_extra_env.clone());
extra_env
}

fn sysroot(&self, dir: &AbsPath) -> Sysroot {
let sysroot_input = self.sysroot.as_ref().map(|p| join_path_buf(dir, p));
let sysroot_src_input = self.sysroot_src.as_ref().map(|p| join_path_buf(dir, p));
match (sysroot_input, sysroot_src_input) {
(None, None) => Sysroot::discover(dir, &self.cargo_extra_env),
(None, None) => Sysroot::discover(dir, &self.get_extra_env()),
(Some(sysroot), None) => Sysroot::discover_rust_lib_src_dir(sysroot),
(None, Some(sysroot_src)) => {
Sysroot::discover_with_src_override(dir, &self.cargo_extra_env, sysroot_src)
Sysroot::discover_with_src_override(dir, &self.get_extra_env(), sysroot_src)
}
(Some(sysroot), Some(sysroot_src)) => Sysroot::new(Some(sysroot), Some(sysroot_src)),
}
Expand Down Expand Up @@ -166,7 +175,7 @@
.map(ToOwned::to_owned)
.map(RustLibSource::Path),

extra_env: self.cargo_extra_env.clone(),
extra_env: self.get_extra_env(),
extra_args: self.cargo_extra_args.clone(),
extra_includes: self
.extra_includes
Expand Down
Loading