Skip to content

Commit

Permalink
feat(resolve): Fallback to 'rustc -V' for MSRV resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Apr 11, 2024
1 parent b7b3874 commit 38718ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ use crate::util::cache_lock::CacheLockMode;
use crate::util::errors::CargoResult;
use crate::util::CanonicalUrl;
use anyhow::Context as _;
use cargo_util_schemas::manifest::RustVersion;
use std::collections::{HashMap, HashSet};
use tracing::{debug, trace};

Expand Down Expand Up @@ -304,8 +303,14 @@ pub fn resolve_with_previous<'gctx>(
version_prefs.version_ordering(VersionOrdering::MinimumVersionsFirst)
}
if ws.resolve_honors_rust_version() {
let rust_version = ws.rust_version().cloned().map(RustVersion::into_partial);
version_prefs.max_rust_version(rust_version);
let rust_version = if let Some(ver) = ws.rust_version() {
ver.clone().into_partial()
} else {
let rustc = ws.gctx().load_global_rustc(Some(ws))?;
let rustc_version = rustc.version.clone().into();
rustc_version
};
version_prefs.max_rust_version(Some(rust_version));
}

let avoid_patch_ids = if register_patches {
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/rust_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ fn resolve_with_rustc() {
"\
[UPDATING] `dummy-registry` index
[LOCKING] 2 packages
[ADDING] bar v1.5.0 (latest: v1.6.0)
",
)
.run();
Expand Down

0 comments on commit 38718ea

Please sign in to comment.