Skip to content

Commit c939267

Browse files
committed
Auto merge of #13790 - epage:install, r=weihanglo
fix(install): Don't respect MSRV for non-local installs ### What does this PR try to resolve? This is part of #9930 ### How should we test and review this PR? ### Additional information
2 parents 125aa57 + dcbf2b5 commit c939267

File tree

6 files changed

+14
-19
lines changed

6 files changed

+14
-19
lines changed

src/bin/cargo/commands/fix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
7272
// code as we can.
7373
let root_manifest = args.root_manifest(gctx)?;
7474
let mut ws = Workspace::new(&root_manifest, gctx)?;
75-
ws.set_honor_rust_version(args.honor_rust_version());
75+
ws.set_resolve_honors_rust_version(args.honor_rust_version());
7676
let mut opts = args.compile_options(gctx, mode, Some(&ws), ProfileChecking::LegacyTestOnly)?;
7777

7878
if !opts.filter.is_specific() {

src/cargo/core/workspace.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ pub struct Workspace<'gctx> {
104104
/// The resolver behavior specified with the `resolver` field.
105105
resolve_behavior: ResolveBehavior,
106106
resolve_honors_rust_version: bool,
107-
honor_rust_version: Option<bool>,
108107

109108
/// Workspace-level custom metadata
110109
custom_metadata: Option<toml::Value>,
@@ -235,7 +234,6 @@ impl<'gctx> Workspace<'gctx> {
235234
ignore_lock: false,
236235
resolve_behavior: ResolveBehavior::V1,
237236
resolve_honors_rust_version: false,
238-
honor_rust_version: None,
239237
custom_metadata: None,
240238
}
241239
}
@@ -649,18 +647,14 @@ impl<'gctx> Workspace<'gctx> {
649647
self.members().filter_map(|pkg| pkg.rust_version()).min()
650648
}
651649

652-
pub fn set_honor_rust_version(&mut self, honor_rust_version: Option<bool>) {
653-
self.honor_rust_version = honor_rust_version;
654-
}
655-
656-
pub fn honor_rust_version(&self) -> Option<bool> {
657-
self.honor_rust_version
650+
pub fn set_resolve_honors_rust_version(&mut self, honor_rust_version: Option<bool>) {
651+
if let Some(honor_rust_version) = honor_rust_version {
652+
self.resolve_honors_rust_version = honor_rust_version;
653+
}
658654
}
659655

660656
pub fn resolve_honors_rust_version(&self) -> bool {
661-
// Give CLI precedence
662-
self.honor_rust_version
663-
.unwrap_or(self.resolve_honors_rust_version)
657+
self.resolve_honors_rust_version
664658
}
665659

666660
pub fn custom_metadata(&self) -> Option<&toml::Value> {

src/cargo/ops/cargo_install.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,9 @@ fn make_ws_rustc_target<'gctx>(
819819
let mut ws = if source_id.is_git() || source_id.is_path() {
820820
Workspace::new(pkg.manifest_path(), gctx)?
821821
} else {
822-
Workspace::ephemeral(pkg, gctx, None, false)?
822+
let mut ws = Workspace::ephemeral(pkg, gctx, None, false)?;
823+
ws.set_resolve_honors_rust_version(Some(false));
824+
ws
823825
};
824826
ws.set_ignore_lock(gctx.lock_update_allowed());
825827
ws.set_require_optional_deps(false);

src/cargo/ops/fix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn fix(
108108
check_resolver_change(&original_ws, opts)?;
109109
}
110110
let mut ws = Workspace::new(&root_manifest, gctx)?;
111-
ws.set_honor_rust_version(original_ws.honor_rust_version());
111+
ws.set_resolve_honors_rust_version(Some(original_ws.resolve_honors_rust_version()));
112112

113113
// Spin up our lock server, which our subprocesses will use to synchronize fixes.
114114
let lock_server = LockServer::new()?;

src/cargo/util/command_prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ pub trait ArgMatchesExt {
505505
fn workspace<'a>(&self, gctx: &'a GlobalContext) -> CargoResult<Workspace<'a>> {
506506
let root = self.root_manifest(gctx)?;
507507
let mut ws = Workspace::new(&root, gctx)?;
508-
ws.set_honor_rust_version(self.honor_rust_version());
508+
ws.set_resolve_honors_rust_version(self.honor_rust_version());
509509
if gctx.cli_unstable().avoid_dev_deps {
510510
ws.set_require_optional_deps(false);
511511
}

tests/testsuite/rust_version.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1146,11 +1146,10 @@ fn cargo_install_ignores_msrv_config() {
11461146
[DOWNLOADING] crates ...
11471147
[DOWNLOADED] foo v0.0.1 (registry [..])
11481148
[INSTALLING] foo v0.0.1
1149-
[LOCKING] 2 packages to latest Rust 1.60 compatible versions
1150-
[ADDING] dep v1.0.0 (latest: v1.1.0)
1149+
[LOCKING] 2 packages to latest compatible versions
11511150
[DOWNLOADING] crates ...
1152-
[DOWNLOADED] dep v1.0.0 (registry [..])
1153-
[COMPILING] dep v1.0.0
1151+
[DOWNLOADED] dep v1.1.0 (registry [..])
1152+
[COMPILING] dep v1.1.0
11541153
[COMPILING] foo v0.0.1
11551154
[FINISHED] `release` profile [optimized] target(s) in [..]
11561155
[INSTALLING] [CWD]/home/.cargo/bin/foo[EXE]

0 commit comments

Comments
 (0)