From 7df4d88b8d55dc62516bca46c2813e2a08240961 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 23 Apr 2024 10:14:38 -0500 Subject: [PATCH] fix(install): Don't respect MSRV for non-local installs This is part of #9930 --- src/cargo/core/workspace.rs | 4 ++++ src/cargo/ops/cargo_install.rs | 4 +++- tests/testsuite/rust_version.rs | 7 +++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index a18080263a54..f66e542a260e 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -657,6 +657,10 @@ impl<'gctx> Workspace<'gctx> { self.honor_rust_version } + pub fn set_resolve_honors_rust_version(&mut self, honor_rust_version: Option) { + self.resolve_honors_rust_version = honor_rust_version; + } + pub fn resolve_honors_rust_version(&self) -> bool { // Give CLI precedence self.honor_rust_version diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 18943dbe46e1..a662e891f387 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -819,7 +819,9 @@ fn make_ws_rustc_target<'gctx>( let mut ws = if source_id.is_git() || source_id.is_path() { Workspace::new(pkg.manifest_path(), gctx)? } else { - Workspace::ephemeral(pkg, gctx, None, false)? + let mut ws = Workspace::ephemeral(pkg, gctx, None, false)?; + ws.set_resolve_honors_rust_version(Some(false)); + ws }; ws.set_ignore_lock(gctx.lock_update_allowed()); ws.set_require_optional_deps(false); diff --git a/tests/testsuite/rust_version.rs b/tests/testsuite/rust_version.rs index 058028462fd7..399779b19fe8 100644 --- a/tests/testsuite/rust_version.rs +++ b/tests/testsuite/rust_version.rs @@ -1146,11 +1146,10 @@ fn cargo_install_ignores_msrv_config() { [DOWNLOADING] crates ... [DOWNLOADED] foo v0.0.1 (registry [..]) [INSTALLING] foo v0.0.1 -[LOCKING] 2 packages to latest Rust 1.60 compatible versions -[ADDING] dep v1.0.0 (latest: v1.1.0) +[LOCKING] 2 packages to latest compatible versions [DOWNLOADING] crates ... -[DOWNLOADED] dep v1.0.0 (registry [..]) -[COMPILING] dep v1.0.0 +[DOWNLOADED] dep v1.1.0 (registry [..]) +[COMPILING] dep v1.1.0 [COMPILING] foo v0.0.1 [FINISHED] `release` profile [optimized] target(s) in [..] [INSTALLING] [CWD]/home/.cargo/bin/foo[EXE]