Skip to content

Commit d9417a3

Browse files
committed
Rust: Force fixed rust-analyzer compatible toolchain
1 parent 8203f08 commit d9417a3

11 files changed

Lines changed: 125 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ use_repo(
139139
"vendor_ts__ra_ap_stdx-0.0.347",
140140
"vendor_ts__ra_ap_syntax-0.0.347",
141141
"vendor_ts__ra_ap_syntax-bridge-0.0.347",
142+
"vendor_ts__ra_ap_toolchain-0.0.347",
142143
"vendor_ts__ra_ap_vfs-0.0.347",
143144
"vendor_ts__rand-0.10.2",
144145
"vendor_ts__rayon-1.12.0",

misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misc/bazel/3rdparty/tree_sitter_extractors_deps/crates.bzl

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misc/bazel/3rdparty/tree_sitter_extractors_deps/ra_ap_toolchain-0.0.347/BUILD.bazel

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misc/bazel/3rdparty/tree_sitter_extractors_deps/ra_ap_toolchain/BUILD.bazel

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/extractor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ra_ap_paths = "0.0.347"
2121
ra_ap_project_model = "0.0.347"
2222
ra_ap_syntax = "0.0.347"
2323
ra_ap_syntax-bridge = "0.0.347"
24+
ra_ap_toolchain = "0.0.347"
2425
ra_ap_vfs = "0.0.347"
2526
ra_ap_parser = "0.0.347"
2627
ra_ap_span = "0.0.347"

rust/extractor/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use std::fmt::Debug;
2424
use std::ops::Not;
2525
use std::path::{Path, PathBuf};
2626

27+
use crate::toolchain::select_toolchain;
28+
2729
#[derive(Debug, PartialEq, Eq, Default, Serialize, Deserialize, Clone, Copy, clap::ValueEnum)]
2830
#[serde(rename_all = "lowercase")]
2931
#[clap(rename_all = "lowercase")]
@@ -140,6 +142,7 @@ impl Config {
140142
);
141143
}
142144
extra_env.extend(self.cargo_extra_env.clone());
145+
extra_env.insert("RUSTUP_TOOLCHAIN".to_owned(), Some(select_toolchain()));
143146
extra_env
144147
}
145148

rust/extractor/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::diagnostics::{ExtractionStep, emit_extraction_diagnostics};
22
use crate::rust_analyzer::{RustAnalyzerNoSemantics, path_to_file_id};
3+
use crate::toolchain::log_project_toolchain;
34
use crate::translate::SourceKind;
45
use crate::trap::TrapId;
56
use anyhow::Context;
@@ -32,6 +33,7 @@ mod diagnostics;
3233
pub mod generated;
3334
mod qltest;
3435
mod rust_analyzer;
36+
mod toolchain;
3537
mod translate;
3638
pub mod trap;
3739

@@ -269,6 +271,7 @@ fn main() -> anyhow::Result<()> {
269271
);
270272
}
271273
let cwd = cwd()?;
274+
log_project_toolchain();
272275
let (cargo_config, load_cargo_config) = cfg.to_cargo_config(&cwd);
273276
let library_mode = if cfg.extract_dependencies_as_source {
274277
SourceKind::Source

rust/extractor/src/qltest.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use itertools::Itertools;
55
use std::ffi::OsStr;
66
use std::fs;
77
use std::path::Path;
8-
use std::process::Command;
98
use tracing::info;
109

1110
const DEFAULT_EDITION: &str = "2021";
@@ -91,15 +90,8 @@ fn set_sources(config: &mut Config) -> anyhow::Result<()> {
9190
}
9291

9392
fn cargo_check(config: &Config) -> anyhow::Result<()> {
94-
let mut command = Command::new("cargo");
93+
let mut command = ra_ap_toolchain::command("cargo", ".", &config.get_extra_env());
9594
command.env("CARGO_TARGET_DIR", config.cargo_target_dir());
96-
// Pass the extra environment variables to the initial `cargo check`.
97-
for (key, value) in config.get_extra_env() {
98-
match value {
99-
Some(value) => command.env(key, value),
100-
None => command.env_remove(key),
101-
};
102-
}
10395
let status = command
10496
.arg("check")
10597
.arg("-q")

0 commit comments

Comments
 (0)