Skip to content

Commit feecbd7

Browse files
committed
fix(config): Adjust MSRV resolve config field name / values
Fixes #13540
1 parent ca330a2 commit feecbd7

File tree

12 files changed

+44
-119
lines changed

12 files changed

+44
-119
lines changed

src/cargo/core/workspace.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::util::lints::{
2929
};
3030
use crate::util::toml::{read_manifest, InheritableFields};
3131
use crate::util::{
32-
context::CargoResolverConfig, context::CargoResolverPrecedence, context::ConfigRelativePath,
32+
context::CargoResolverConfig, context::ConfigRelativePath, context::IncompatibleRustVersions,
3333
Filesystem, GlobalContext, IntoUrl,
3434
};
3535
use cargo_util::paths;
@@ -320,19 +320,19 @@ impl<'gctx> Workspace<'gctx> {
320320
}
321321
match self.gctx().get::<CargoResolverConfig>("resolver") {
322322
Ok(CargoResolverConfig {
323-
something_like_precedence: Some(precedence),
323+
incompatible_rust_versions: Some(incompatible_rust_versions),
324324
}) => {
325325
if self.gctx().cli_unstable().msrv_policy {
326326
self.resolve_honors_rust_version =
327-
precedence == CargoResolverPrecedence::SomethingLikeRustVersion;
327+
incompatible_rust_versions == IncompatibleRustVersions::Fallback;
328328
} else {
329329
self.gctx()
330330
.shell()
331331
.warn("ignoring `resolver` config table without `-Zmsrv-policy`")?;
332332
}
333333
}
334334
Ok(CargoResolverConfig {
335-
something_like_precedence: None,
335+
incompatible_rust_versions: None,
336336
}) => {}
337337
Err(err) => {
338338
if self.gctx().cli_unstable().msrv_policy {

src/cargo/util/context/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2680,14 +2680,14 @@ impl BuildTargetConfig {
26802680
#[derive(Debug, Deserialize)]
26812681
#[serde(rename_all = "kebab-case")]
26822682
pub struct CargoResolverConfig {
2683-
pub something_like_precedence: Option<CargoResolverPrecedence>,
2683+
pub incompatible_rust_versions: Option<IncompatibleRustVersions>,
26842684
}
26852685

26862686
#[derive(Debug, Deserialize, PartialEq, Eq)]
26872687
#[serde(rename_all = "kebab-case")]
2688-
pub enum CargoResolverPrecedence {
2689-
SomethingLikeMaximum,
2690-
SomethingLikeRustVersion,
2688+
pub enum IncompatibleRustVersions {
2689+
Allow,
2690+
Fallback,
26912691
}
26922692

26932693
#[derive(Deserialize, Default)]

src/doc/src/reference/unstable.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -338,26 +338,26 @@ This was stabilized in 1.79 in [#13608](https://github.com/rust-lang/cargo/pull/
338338
### MSRV-aware resolver
339339

340340
`-Zmsrv-policy` allows access to an MSRV-aware resolver which can be enabled with:
341-
- `resolver.something-like-precedence` config field
341+
- `resolver.incompatible-rust-versions` config field
342342
- `workspace.resolver = "3"` / `package.resolver = "3"`
343343
- `package.edition = "2024"` (only in workspace root)
344344

345345
The resolver will prefer dependencies with a `package.rust-version` that is the same or older than your project's MSRV.
346346
Your project's MSRV is determined by taking the lowest `package.rust-version` set among your workspace members.
347347
If there is none set, your toolchain version will be used with the intent to pick up the version from rustup's `rust-toolchain.toml`, if present.
348348

349-
#### `resolver.something-like-precedence`
349+
#### `resolver.incompatible-rust-versions`
350350
* Type: string
351-
* Default: "something-like-maximum"
352-
* Environment: `CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE`
351+
* Default: "allow"
352+
* Environment: `CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS`
353353

354-
Select which policy should be used when resolving dependencies. Values include
355-
- `something-like-maximum`: prefer highest compatible versions of a package
356-
- `something-like-rust-version`: prefer versions of packages compatible with your project's Rust version
354+
Select how packages with incompatible rust-versions should be resolved. Values include:
355+
- `allow`: treat them like any other dependency
356+
- `fallback`: only consider them if no other dependency version matched
357357

358358
Can be overridden with
359359
- `--ignore-rust-version` CLI option
360-
- Setting the dependency's version requirement too high
360+
- Setting the dependency's version requirement above any version that is rust-version compatible
361361
- Specifying the version to `cargo update` with `--precise`
362362

363363
## precise-pre-release

tests/testsuite/cargo_add/rust_version_ignore/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ fn case() {
2525
.arg("--ignore-rust-version")
2626
.arg_line("rust-version-user")
2727
.current_dir(cwd)
28-
.env(
29-
"CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE",
30-
"something-like-rust-version",
31-
)
28+
.env("CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS", "fallback")
3229
.masquerade_as_nightly_cargo(&["msrv-policy"])
3330
.assert()
3431
.code(0)

tests/testsuite/cargo_add/rust_version_incompatible/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ fn case() {
2727
.arg("add")
2828
.arg_line("rust-version-user")
2929
.current_dir(cwd)
30-
.env(
31-
"CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE",
32-
"something-like-rust-version",
33-
)
30+
.env("CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS", "fallback")
3431
.masquerade_as_nightly_cargo(&["msrv-policy"])
3532
.assert()
3633
.failure()

tests/testsuite/cargo_add/rust_version_latest/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ fn case() {
2424
.arg("add")
2525
.arg_line("rust-version-user")
2626
.current_dir(cwd)
27-
.env(
28-
"CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE",
29-
"something-like-rust-version",
30-
)
27+
.env("CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS", "fallback")
3128
.masquerade_as_nightly_cargo(&["msrv-policy"])
3229
.assert()
3330
.success()

tests/testsuite/cargo_add/rust_version_older/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ fn case() {
2424
.arg("add")
2525
.arg_line("rust-version-user")
2626
.current_dir(cwd)
27-
.env(
28-
"CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE",
29-
"something-like-rust-version",
30-
)
27+
.env("CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS", "fallback")
3128
.masquerade_as_nightly_cargo(&["msrv-policy"])
3229
.assert()
3330
.success()

tests/testsuite/cargo_add/rustc_ignore/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ fn case() {
2828
.arg("--ignore-rust-version")
2929
.arg_line("rust-version-user")
3030
.current_dir(cwd)
31-
.env(
32-
"CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE",
33-
"something-like-rust-version",
34-
)
31+
.env("CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS", "fallback")
3532
.masquerade_as_nightly_cargo(&["msrv-policy"])
3633
.assert()
3734
.code(0)

tests/testsuite/cargo_add/rustc_incompatible/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ fn case() {
2121
.arg("add")
2222
.arg_line("rust-version-user")
2323
.current_dir(cwd)
24-
.env(
25-
"CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE",
26-
"something-like-rust-version",
27-
)
24+
.env("CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS", "fallback")
2825
.masquerade_as_nightly_cargo(&["msrv-policy"])
2926
.assert()
3027
.failure()

tests/testsuite/cargo_add/rustc_latest/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ fn case() {
2727
.arg("add")
2828
.arg_line("rust-version-user")
2929
.current_dir(cwd)
30-
.env(
31-
"CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE",
32-
"something-like-rust-version",
33-
)
30+
.env("CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS", "fallback")
3431
.masquerade_as_nightly_cargo(&["msrv-policy"])
3532
.assert()
3633
.success()

tests/testsuite/cargo_add/rustc_older/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ fn case() {
2727
.arg("add")
2828
.arg_line("rust-version-user")
2929
.current_dir(cwd)
30-
.env(
31-
"CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE",
32-
"something-like-rust-version",
33-
)
30+
.env("CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS", "fallback")
3431
.masquerade_as_nightly_cargo(&["msrv-policy"])
3532
.assert()
3633
.success()

0 commit comments

Comments
 (0)