Skip to content

Commit 7b58bd5

Browse files
committed
feat(resolver): Stabilize v3 resolver
1 parent c54a8e8 commit 7b58bd5

File tree

4 files changed

+5
-40
lines changed

4 files changed

+5
-40
lines changed

src/cargo/util/toml/mod.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,6 @@ fn normalize_toml(
273273
warnings: &mut Vec<String>,
274274
errors: &mut Vec<String>,
275275
) -> CargoResult<manifest::TomlManifest> {
276-
if let Some(workspace) = &original_toml.workspace {
277-
if workspace.resolver.as_deref() == Some("3") {
278-
features.require(Feature::edition2024())?;
279-
}
280-
}
281-
282276
let mut normalized_toml = manifest::TomlManifest {
283277
cargo_features: original_toml.cargo_features.clone(),
284278
package: None,
@@ -316,8 +310,7 @@ fn normalize_toml(
316310
if let Some(original_package) = original_toml.package() {
317311
let package_name = &original_package.name;
318312

319-
let normalized_package =
320-
normalize_package_toml(original_package, features, package_root, &inherit)?;
313+
let normalized_package = normalize_package_toml(original_package, package_root, &inherit)?;
321314
let edition = normalized_package
322315
.normalized_edition()
323316
.expect("previously normalized")
@@ -549,7 +542,6 @@ fn normalize_patch<'a>(
549542
#[tracing::instrument(skip_all)]
550543
fn normalize_package_toml<'a>(
551544
original_package: &manifest::TomlPackage,
552-
features: &Features,
553545
package_root: &Path,
554546
inherit: &dyn Fn() -> CargoResult<&'a InheritableFields>,
555547
) -> CargoResult<Box<manifest::TomlPackage>> {
@@ -682,10 +674,6 @@ fn normalize_package_toml<'a>(
682674
_invalid_cargo_features: Default::default(),
683675
};
684676

685-
if normalized_package.resolver.as_deref() == Some("3") {
686-
features.require(Feature::edition2024())?;
687-
}
688-
689677
Ok(Box::new(normalized_package))
690678
}
691679

src/doc/src/reference/config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ The `[resolver]` table overrides [dependency resolution behavior](resolver.md) f
981981

982982
#### `resolver.incompatible-rust-versions`
983983
* Type: string
984-
* Default: `"allow"`
984+
* Default: See [`resolver`](resolver.md#resolver-versions) docs
985985
* Environment: `CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS`
986986

987987
When resolving which version of a dependency to use, select how versions with incompatible `package.rust-version`s are treated.

src/doc/src/reference/resolver.md

+1
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ resolver = "2"
507507
- `"2"` ([`edition = "2021"`](manifest.md#the-edition-field) default): Introduces changes in [feature
508508
unification](#features). See the [features chapter][features-2] for more
509509
details.
510+
- `"3"` (requires Rust 1.84+): Change the default for [`resolver.incompatible-rust-versions`] from `allow` to `fallback`
510511

511512
The resolver is a global option that affects the entire workspace. The
512513
`resolver` version in dependencies is ignored, only the value in the top-level

tests/testsuite/rust_version.rs

+2-26
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ foo v0.0.1 ([ROOT]/foo)
612612
.run();
613613
}
614614

615-
#[cargo_test(nightly, reason = "edition2024 in rustc is unstable")]
615+
#[cargo_test]
616616
fn resolve_v3() {
617617
Package::new("only-newer", "1.6.0")
618618
.rust_version("1.65.0")
@@ -631,8 +631,6 @@ fn resolve_v3() {
631631
.file(
632632
"Cargo.toml",
633633
r#"
634-
cargo-features = ["edition2024"]
635-
636634
[package]
637635
name = "foo"
638636
version = "0.0.1"
@@ -651,7 +649,6 @@ fn resolve_v3() {
651649

652650
// v3 should resolve for MSRV
653651
p.cargo("generate-lockfile")
654-
.masquerade_as_nightly_cargo(&["edition2024"])
655652
.with_stderr_data(str![[r#"
656653
[UPDATING] `dummy-registry` index
657654
[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions
@@ -661,7 +658,6 @@ fn resolve_v3() {
661658
"#]])
662659
.run();
663660
p.cargo("tree")
664-
.masquerade_as_nightly_cargo(&["edition2024"])
665661
.with_stdout_data(str![[r#"
666662
foo v0.0.1 ([ROOT]/foo)
667663
├── newer-and-older v1.5.0
@@ -677,10 +673,8 @@ foo v0.0.1 ([ROOT]/foo)
677673
[LOCKING] 2 packages to latest compatible versions
678674
679675
"#]])
680-
.masquerade_as_nightly_cargo(&["edition2024"])
681676
.run();
682677
p.cargo("tree")
683-
.masquerade_as_nightly_cargo(&["edition2024"])
684678
.with_stdout_data(str![[r#"
685679
foo v0.0.1 ([ROOT]/foo)
686680
├── newer-and-older v1.6.0
@@ -697,29 +691,13 @@ foo v0.0.1 ([ROOT]/foo)
697691
[LOCKING] 2 packages to latest compatible versions
698692
699693
"#]])
700-
.masquerade_as_nightly_cargo(&["edition2024"])
701694
.run();
702695
p.cargo("tree")
703-
.masquerade_as_nightly_cargo(&["edition2024"])
704696
.with_stdout_data(str![[r#"
705697
foo v0.0.1 ([ROOT]/foo)
706698
├── newer-and-older v1.6.0
707699
└── only-newer v1.6.0
708700
709-
"#]])
710-
.run();
711-
712-
// unstable
713-
p.cargo("generate-lockfile")
714-
.with_status(101)
715-
.with_stderr_data(str![[r#"
716-
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
717-
718-
Caused by:
719-
the cargo feature `edition2024` requires a nightly version of Cargo, but this is the `stable` channel
720-
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
721-
See https://doc.rust-lang.org/cargo/reference/unstable.html#edition-2024 for more information about using this feature.
722-
723701
"#]])
724702
.run();
725703
}
@@ -946,7 +924,7 @@ fn cargo_install_ignores_msrv_config() {
946924
.run();
947925
}
948926

949-
#[cargo_test(nightly, reason = "edition2024 in rustc is unstable")]
927+
#[cargo_test]
950928
fn cargo_install_ignores_resolver_v3_msrv_change() {
951929
Package::new("dep", "1.0.0")
952930
.rust_version("1.50")
@@ -958,14 +936,12 @@ fn cargo_install_ignores_resolver_v3_msrv_change() {
958936
.publish();
959937
Package::new("foo", "0.0.1")
960938
.rust_version("1.60")
961-
.cargo_feature("edition2024")
962939
.resolver("3")
963940
.file("src/main.rs", "fn main() {}")
964941
.dep("dep", "1")
965942
.publish();
966943

967944
cargo_process("install foo")
968-
.masquerade_as_nightly_cargo(&["edition2024"])
969945
.with_stderr_data(str![[r#"
970946
[UPDATING] `dummy-registry` index
971947
[DOWNLOADING] crates ...

0 commit comments

Comments
 (0)