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
This commit is contained in:
bors 2024-04-23 19:35:19 +00:00
commit c939267591
6 changed files with 14 additions and 19 deletions

View File

@ -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() {

View File

@ -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>,
@ -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,
}
}
@ -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 {
// 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> {

View File

@ -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);

View File

@ -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()?;

View File

@ -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);
}

View File

@ -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]