mirror of https://github.com/rust-lang/cargo
refactor(msrv): Simplify tracking of use of MSRV-aware resolver
The design for this stems from - It being unclear what the initialization order would be - Prematurely writing this for `Cargo.lock` version to leverage it and maybe to switch other MSRV-aware logic to
This commit is contained in:
parent
b89b81a6c7
commit
cd8d5f7c10
|
@ -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() {
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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()?;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue