mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Set RUSTC_SYSROOT for runnables
This commit is contained in:
parent
2346a80ab4
commit
33ce9a4211
8 changed files with 59 additions and 43 deletions
|
@ -579,6 +579,7 @@ impl GlobalStateSnapshot {
|
|||
target_kind: target_data.kind,
|
||||
required_features: target_data.required_features.clone(),
|
||||
features: package_data.features.keys().cloned().collect(),
|
||||
sysroot_root: workspace.sysroot.root().map(ToOwned::to_owned),
|
||||
}));
|
||||
}
|
||||
ProjectWorkspaceKind::Json(project) => {
|
||||
|
|
|
@ -50,7 +50,7 @@ use crate::{
|
|||
self, CrateInfoResult, ExternalDocsPair, ExternalDocsResponse, FetchDependencyListParams,
|
||||
FetchDependencyListResult, PositionOrRange, ViewCrateGraphParams, WorkspaceSymbolParams,
|
||||
},
|
||||
target_spec::TargetSpec,
|
||||
target_spec::{CargoTargetSpec, TargetSpec},
|
||||
};
|
||||
|
||||
pub(crate) fn handle_workspace_reload(state: &mut GlobalState, _: ()) -> anyhow::Result<()> {
|
||||
|
@ -848,6 +848,14 @@ pub(crate) fn handle_runnables(
|
|||
if let lsp_ext::RunnableArgs::Cargo(r) = &mut runnable.args {
|
||||
runnable.label = format!("{} + expect", runnable.label);
|
||||
r.environment.insert("UPDATE_EXPECT".to_owned(), "1".to_owned());
|
||||
if let Some(TargetSpec::Cargo(CargoTargetSpec {
|
||||
sysroot_root: Some(sysroot_root),
|
||||
..
|
||||
})) = &target_spec
|
||||
{
|
||||
r.environment
|
||||
.insert("RUSTC_TOOLCHAIN".to_owned(), sysroot_root.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
res.push(runnable);
|
||||
|
@ -889,7 +897,12 @@ pub(crate) fn handle_runnables(
|
|||
override_cargo: config.override_cargo.clone(),
|
||||
cargo_args,
|
||||
executable_args: Vec::new(),
|
||||
environment: Default::default(),
|
||||
environment: spec
|
||||
.sysroot_root
|
||||
.as_ref()
|
||||
.map(|root| ("RUSTC_TOOLCHAIN".to_owned(), root.to_string()))
|
||||
.into_iter()
|
||||
.collect(),
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1399,7 +1399,11 @@ pub(crate) fn runnable(
|
|||
cargo_args,
|
||||
cwd: cwd.into(),
|
||||
executable_args,
|
||||
environment: Default::default(),
|
||||
environment: spec
|
||||
.sysroot_root
|
||||
.map(|root| ("RUSTC_TOOLCHAIN".to_owned(), root.to_string()))
|
||||
.into_iter()
|
||||
.collect(),
|
||||
}),
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ pub(crate) struct CargoTargetSpec {
|
|||
pub(crate) crate_id: CrateId,
|
||||
pub(crate) required_features: Vec<String>,
|
||||
pub(crate) features: FxHashSet<String>,
|
||||
pub(crate) sysroot_root: Option<vfs::AbsPathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue