diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index 8a901de8ae5..8190cf07e95 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -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() { diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index c3b04806ea0..c73d0ce3801 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -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, /// Workspace-level custom metadata custom_metadata: Option, @@ -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) { - self.honor_rust_version = honor_rust_version; - } - - pub fn honor_rust_version(&self) -> Option { - self.honor_rust_version + pub fn set_resolve_honors_rust_version(&mut self, honor_rust_version: Option) { + 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> { diff --git a/src/cargo/ops/fix.rs b/src/cargo/ops/fix.rs index 88c90e31af4..743bd486646 100644 --- a/src/cargo/ops/fix.rs +++ b/src/cargo/ops/fix.rs @@ -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()?; diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 0f3d3dc437c..63435b50eaa 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -505,7 +505,7 @@ pub trait ArgMatchesExt { fn workspace<'a>(&self, gctx: &'a GlobalContext) -> CargoResult> { 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); }