Skip to content

Commit 28274d0

Browse files
committed
Auto merge of #14724 - epage:resolver, r=weihanglo
test(install): Verify 2024 edition / resolver=3 doesn't affect resolution ### What does this PR try to resolve? I was worried there might be bugs related to this. With this out of the way, I think we'll be ready to stabilize `resolver = "3"`. ### How should we test and review this PR? ### Additional information
2 parents 8315873 + 487bbc8 commit 28274d0

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed

crates/cargo-test-support/src/registry.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ pub struct Package {
571571
local: bool,
572572
alternative: bool,
573573
invalid_json: bool,
574+
edition: Option<String>,
575+
resolver: Option<String>,
574576
proc_macro: bool,
575577
links: Option<String>,
576578
rust_version: Option<String>,
@@ -1250,6 +1252,8 @@ impl Package {
12501252
local: false,
12511253
alternative: false,
12521254
invalid_json: false,
1255+
edition: None,
1256+
resolver: None,
12531257
proc_macro: false,
12541258
links: None,
12551259
rust_version: None,
@@ -1385,6 +1389,18 @@ impl Package {
13851389
self
13861390
}
13871391

1392+
/// Specifies `package.edition`
1393+
pub fn edition(&mut self, edition: &str) -> &mut Package {
1394+
self.edition = Some(edition.to_owned());
1395+
self
1396+
}
1397+
1398+
/// Specifies `package.resolver`
1399+
pub fn resolver(&mut self, resolver: &str) -> &mut Package {
1400+
self.resolver = Some(resolver.to_owned());
1401+
self
1402+
}
1403+
13881404
/// Specifies whether or not this is a proc macro.
13891405
pub fn proc_macro(&mut self, proc_macro: bool) -> &mut Package {
13901406
self.proc_macro = proc_macro;
@@ -1570,7 +1586,15 @@ impl Package {
15701586
));
15711587

15721588
if let Some(version) = &self.rust_version {
1573-
manifest.push_str(&format!("rust-version = \"{}\"", version));
1589+
manifest.push_str(&format!("rust-version = \"{}\"\n", version));
1590+
}
1591+
1592+
if let Some(edition) = &self.edition {
1593+
manifest.push_str(&format!("edition = \"{}\"\n", edition));
1594+
}
1595+
1596+
if let Some(resolver) = &self.resolver {
1597+
manifest.push_str(&format!("resolver = \"{}\"\n", resolver));
15741598
}
15751599

15761600
if !self.features.is_empty() {

tests/testsuite/rust_version.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,86 @@ fn cargo_install_ignores_msrv_config() {
958958
.run();
959959
}
960960

961+
#[cargo_test(nightly, reason = "edition2024 in rustc is unstable")]
962+
fn cargo_install_ignores_resolver_v3_msrv_change() {
963+
Package::new("dep", "1.0.0")
964+
.rust_version("1.50")
965+
.file("src/lib.rs", "fn hello() {}")
966+
.publish();
967+
Package::new("dep", "1.1.0")
968+
.rust_version("1.70")
969+
.file("src/lib.rs", "fn hello() {}")
970+
.publish();
971+
Package::new("foo", "0.0.1")
972+
.rust_version("1.60")
973+
.cargo_feature("edition2024")
974+
.resolver("3")
975+
.file("src/main.rs", "fn main() {}")
976+
.dep("dep", "1")
977+
.publish();
978+
979+
cargo_process("install foo")
980+
.arg("-Zmsrv-policy")
981+
.masquerade_as_nightly_cargo(&["edition2024", "msrv-policy"])
982+
.with_stderr_data(str![[r#"
983+
[UPDATING] `dummy-registry` index
984+
[DOWNLOADING] crates ...
985+
[DOWNLOADED] foo v0.0.1 (registry `dummy-registry`)
986+
[INSTALLING] foo v0.0.1
987+
[LOCKING] 1 package to latest compatible version
988+
[DOWNLOADING] crates ...
989+
[DOWNLOADED] dep v1.1.0 (registry `dummy-registry`)
990+
[COMPILING] dep v1.1.0
991+
[COMPILING] foo v0.0.1
992+
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
993+
[INSTALLING] [ROOT]/home/.cargo/bin/foo[EXE]
994+
[INSTALLED] package `foo v0.0.1` (executable `foo[EXE]`)
995+
[WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries
996+
997+
"#]])
998+
.run();
999+
}
1000+
1001+
#[cargo_test(nightly, reason = "edition2024 in rustc is unstable")]
1002+
fn cargo_install_ignores_edition_2024_msrv_change() {
1003+
Package::new("dep", "1.0.0")
1004+
.rust_version("1.50")
1005+
.file("src/lib.rs", "fn hello() {}")
1006+
.publish();
1007+
Package::new("dep", "1.1.0")
1008+
.rust_version("1.70")
1009+
.file("src/lib.rs", "fn hello() {}")
1010+
.publish();
1011+
Package::new("foo", "0.0.1")
1012+
.rust_version("1.60")
1013+
.cargo_feature("edition2024")
1014+
.edition("2024")
1015+
.file("src/main.rs", "fn main() {}")
1016+
.dep("dep", "1")
1017+
.publish();
1018+
1019+
cargo_process("install foo")
1020+
.arg("-Zmsrv-policy")
1021+
.masquerade_as_nightly_cargo(&["edition2024", "msrv-policy"])
1022+
.with_stderr_data(str![[r#"
1023+
[UPDATING] `dummy-registry` index
1024+
[DOWNLOADING] crates ...
1025+
[DOWNLOADED] foo v0.0.1 (registry `dummy-registry`)
1026+
[INSTALLING] foo v0.0.1
1027+
[LOCKING] 1 package to latest compatible version
1028+
[DOWNLOADING] crates ...
1029+
[DOWNLOADED] dep v1.1.0 (registry `dummy-registry`)
1030+
[COMPILING] dep v1.1.0
1031+
[COMPILING] foo v0.0.1
1032+
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
1033+
[INSTALLING] [ROOT]/home/.cargo/bin/foo[EXE]
1034+
[INSTALLED] package `foo v0.0.1` (executable `foo[EXE]`)
1035+
[WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries
1036+
1037+
"#]])
1038+
.run();
1039+
}
1040+
9611041
#[cargo_test]
9621042
fn report_rust_versions() {
9631043
Package::new("dep-only-low-compatible", "1.55.0")

0 commit comments

Comments
 (0)