Skip to content

Commit 626fa3d

Browse files
committed
Rust: Pass --ignore-rust-version to Cargo
1 parent 4fcecf2 commit 626fa3d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎rust/extractor/src/config.rs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ impl Config {
189189

190190
pub fn to_cargo_config(&self, dir: &AbsPath) -> (CargoConfig, LoadCargoConfig) {
191191
let sysroot = self.sysroot(dir);
192+
let mut extra_args = self.cargo_extra_args.clone();
193+
// The fixed toolchain may be older than the project's declared minimum. If that's the case
194+
// `cargo` will error. Passing the flag below ensures that the project's specified Rust
195+
// version is ignored. With this failures will only occur if the project actually uses Rust
196+
// features that rust-analyzer can't understand (which is the best we can hope for).
197+
if !extra_args.iter().any(|arg| arg == "--ignore-rust-version") {
198+
extra_args.push("--ignore-rust-version".to_owned());
199+
}
192200
(
193201
CargoConfig {
194202
all_targets: self.cargo_all_targets,
@@ -205,7 +213,7 @@ impl Config {
205213
.map(RustLibSource::Path),
206214

207215
extra_env: self.get_extra_env(),
208-
extra_args: self.cargo_extra_args.clone(),
216+
extra_args,
209217
extra_includes: self
210218
.extra_includes
211219
.iter()

0 commit comments

Comments
 (0)