Skip to content

Commit 5f07992

Browse files
committed
refactor(ws): Clarify what rust-version is used
For workflows like `cargo info`, this call will live on regardless of what we do with the resolver.
1 parent e94fde9 commit 5f07992

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/cargo/core/workspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ impl<'gctx> Workspace<'gctx> {
664664

665665
/// Get the lowest-common denominator `package.rust-version` within the workspace, if specified
666666
/// anywhere
667-
pub fn rust_version(&self) -> Option<&RustVersion> {
667+
pub fn lowest_rust_version(&self) -> Option<&RustVersion> {
668668
self.members().filter_map(|pkg| pkg.rust_version()).min()
669669
}
670670

src/cargo/ops/cargo_update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ fn required_rust_version(ws: &Workspace<'_>) -> Option<PartialVersion> {
739739
return None;
740740
}
741741

742-
if let Some(ver) = ws.rust_version() {
742+
if let Some(ver) = ws.lowest_rust_version() {
743743
Some(ver.clone().into_partial())
744744
} else {
745745
let rustc = ws.gctx().load_global_rustc(Some(ws)).ok()?;

src/cargo/ops/lockfile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn write_pkg_lockfile(ws: &Workspace<'_>, resolve: &mut Resolve) -> CargoRes
7171
// out lock file updates as they're otherwise already updated, and changes
7272
// which don't touch dependencies won't seemingly spuriously update the lock
7373
// file.
74-
let default_version = ResolveVersion::with_rust_version(ws.rust_version());
74+
let default_version = ResolveVersion::with_rust_version(ws.lowest_rust_version());
7575
let current_version = resolve.version();
7676
let next_lockfile_bump = ws.gctx().cli_unstable().next_lockfile_bump;
7777
tracing::debug!("lockfile - current: {current_version:?}, default: {default_version:?}");

src/cargo/ops/registry/info/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,6 @@ fn try_get_msrv_from_nearest_manifest_or_ws(
217217
let rust_version = nearest_package.and_then(|p| p.rust_version().map(|v| v.as_partial()));
218218
// If the nearest manifest does not have a specific Rust version, try to get it from the workspace.
219219
rust_version
220-
.or_else(|| ws.and_then(|ws| ws.rust_version().map(|v| v.as_partial())))
220+
.or_else(|| ws.and_then(|ws| ws.lowest_rust_version().map(|v| v.as_partial())))
221221
.cloned()
222222
}

src/cargo/ops/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ pub fn resolve_with_previous<'gctx>(
357357
version_prefs.version_ordering(VersionOrdering::MinimumVersionsFirst)
358358
}
359359
if ws.resolve_honors_rust_version() {
360-
let rust_version = if let Some(ver) = ws.rust_version() {
360+
let rust_version = if let Some(ver) = ws.lowest_rust_version() {
361361
ver.clone().into_partial()
362362
} else {
363363
let rustc = ws.gctx().load_global_rustc(Some(ws))?;
@@ -422,7 +422,7 @@ pub fn resolve_with_previous<'gctx>(
422422
&replace,
423423
registry,
424424
&version_prefs,
425-
ResolveVersion::with_rust_version(ws.rust_version()),
425+
ResolveVersion::with_rust_version(ws.lowest_rust_version()),
426426
Some(ws.gctx()),
427427
)?;
428428

0 commit comments

Comments
 (0)