Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(install): Don't respect MSRV for non-local installs #13790

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
// code as we can.
let root_manifest = args.root_manifest(gctx)?;
let mut ws = Workspace::new(&root_manifest, gctx)?;
ws.set_honor_rust_version(args.honor_rust_version());
ws.set_resolve_honors_rust_version(args.honor_rust_version());
let mut opts = args.compile_options(gctx, mode, Some(&ws), ProfileChecking::LegacyTestOnly)?;

if !opts.filter.is_specific() {
Expand Down
16 changes: 5 additions & 11 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ pub struct Workspace<'gctx> {
/// The resolver behavior specified with the `resolver` field.
resolve_behavior: ResolveBehavior,
resolve_honors_rust_version: bool,
honor_rust_version: Option<bool>,

/// Workspace-level custom metadata
custom_metadata: Option<toml::Value>,
Expand Down Expand Up @@ -235,7 +234,6 @@ impl<'gctx> Workspace<'gctx> {
ignore_lock: false,
resolve_behavior: ResolveBehavior::V1,
resolve_honors_rust_version: false,
honor_rust_version: None,
custom_metadata: None,
}
}
Expand Down Expand Up @@ -649,18 +647,14 @@ impl<'gctx> Workspace<'gctx> {
self.members().filter_map(|pkg| pkg.rust_version()).min()
}

pub fn set_honor_rust_version(&mut self, honor_rust_version: Option<bool>) {
self.honor_rust_version = honor_rust_version;
}

pub fn honor_rust_version(&self) -> Option<bool> {
self.honor_rust_version
pub fn set_resolve_honors_rust_version(&mut self, honor_rust_version: Option<bool>) {
if let Some(honor_rust_version) = honor_rust_version {
self.resolve_honors_rust_version = honor_rust_version;
}
}

pub fn resolve_honors_rust_version(&self) -> bool {
epage marked this conversation as resolved.
Show resolved Hide resolved
// Give CLI precedence
self.honor_rust_version
.unwrap_or(self.resolve_honors_rust_version)
self.resolve_honors_rust_version
}

pub fn custom_metadata(&self) -> Option<&toml::Value> {
Expand Down
4 changes: 3 additions & 1 deletion src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn fix(
check_resolver_change(&original_ws, opts)?;
}
let mut ws = Workspace::new(&root_manifest, gctx)?;
ws.set_honor_rust_version(original_ws.honor_rust_version());
ws.set_resolve_honors_rust_version(Some(original_ws.resolve_honors_rust_version()));

// Spin up our lock server, which our subprocesses will use to synchronize fixes.
let lock_server = LockServer::new()?;
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ pub trait ArgMatchesExt {
fn workspace<'a>(&self, gctx: &'a GlobalContext) -> CargoResult<Workspace<'a>> {
let root = self.root_manifest(gctx)?;
let mut ws = Workspace::new(&root, gctx)?;
ws.set_honor_rust_version(self.honor_rust_version());
ws.set_resolve_honors_rust_version(self.honor_rust_version());
if gctx.cli_unstable().avoid_dev_deps {
ws.set_require_optional_deps(false);
}
Expand Down
7 changes: 3 additions & 4 deletions tests/testsuite/rust_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down