From f30f909756cfad1dc29a5c5040408351fae1ae3f Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 24 Sep 2024 15:35:47 -0400 Subject: [PATCH 1/3] refactor(resolve): reuse RustVersion construct --- src/cargo/core/resolver/resolve.rs | 33 ++++++++++++------------------ 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/cargo/core/resolver/resolve.rs b/src/cargo/core/resolver/resolve.rs index c572e27d5e03..2da7fd5c2176 100644 --- a/src/cargo/core/resolver/resolve.rs +++ b/src/cargo/core/resolver/resolve.rs @@ -125,28 +125,21 @@ impl ResolveVersion { return ResolveVersion::default(); }; - let rust_1_41 = PartialVersion { - major: 1, - minor: Some(41), - patch: None, - pre: None, - build: None, - } - .try_into() - .expect("PartialVersion 1.41"); - let rust_1_53 = PartialVersion { - major: 1, - minor: Some(53), - patch: None, - pre: None, - build: None, - } - .try_into() - .expect("PartialVersion 1.53"); + let rust = |major, minor| -> RustVersion { + PartialVersion { + major, + minor: Some(minor), + patch: None, + pre: None, + build: None, + } + .try_into() + .unwrap() + }; - if rust_version >= &rust_1_53 { + if rust_version >= &rust(1, 53) { ResolveVersion::V3 - } else if rust_version >= &rust_1_41 { + } else if rust_version >= &rust(1, 41) { ResolveVersion::V2 } else { ResolveVersion::V1 From f3672cbf3925f3ab91725bc2d4aa5cd04aaf43f4 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 24 Sep 2024 17:32:29 -0400 Subject: [PATCH 2/3] test(lockfile): default lockfile version is still v3 It will become v4 when we changes the default. --- tests/testsuite/lockfile_compat.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/testsuite/lockfile_compat.rs b/tests/testsuite/lockfile_compat.rs index 18ec5bc2d8f8..aa22b0715950 100644 --- a/tests/testsuite/lockfile_compat.rs +++ b/tests/testsuite/lockfile_compat.rs @@ -1175,6 +1175,26 @@ fn v4_and_git_url_encoded_rev() { #[cargo_test] fn with_msrv() { let cksum = Package::new("bar", "0.1.0").publish(); + + let v3_lockfile = format!( + r#"# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bar" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "{cksum}" + +[[package]] +name = "foo" +version = "0.0.1" +dependencies = [ + "bar", +] +"# + ); let v2_lockfile = format!( r#"# This file is automatically @generated by Cargo. # It is not intended for manual editing. @@ -1258,6 +1278,14 @@ dependencies = [ ("1.53", Some(4), 4), // v4 introduced ("1.78", None, 3), + // last version of v3 as the default + ("1.82", None, 3), + // v4 is the default + ("1.83", None, 3), + ("1.83", Some(1), 1), + ("1.83", Some(2), 2), + ("1.83", Some(3), 3), + ("1.83", Some(4), 4), ]; for (msrv, existing_lockfile, expected_version) in cases { @@ -1284,6 +1312,7 @@ dependencies = [ let existing_lockfile = match existing_lockfile { 1 => v1_lockfile.as_str().into(), 2 => v2_lockfile.as_str().into(), + 3 => v3_lockfile.as_str().into(), v => std::borrow::Cow::from(format!("version = {v}")), }; p.change_file("Cargo.lock", &existing_lockfile); From 5dfdd59009930729787e59049c988a7d18b9f5a1 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 24 Sep 2024 15:36:52 -0400 Subject: [PATCH 3/3] feat: make lockfile v4 the default This commit makes lockfile version 4 the default version when Cargo tries to write to a lockfile. The lockfile version 4 has been stabilized since 1.78.0, and will become default in 1.83.0. the length of transition period is pretty similar as before. One caveat is that in other output from Cargo, e.g., `cargo metatada`, status messages, `SourceID` will display in the v4 URL encoded format. This shouldn't affect the majority of Rust users, as `SourceId` representation should be opaque to them, unless comparing `SourceId` across different version of toolchains. --- src/cargo/core/resolver/resolve.rs | 9 ++-- src/cargo/core/source_id.rs | 5 +- src/cargo/sources/git/source.rs | 6 +-- src/cargo/util/toml_mut/dependency.rs | 6 +-- tests/testsuite/alt_registry.rs | 2 +- .../add_workspace_non_fuzzy/in/Cargo.lock | 2 +- .../cargo_add/locked_unchanged/in/Cargo.lock | 2 +- .../cargo_add/lockfile_updated/in/Cargo.lock | 2 +- .../cargo_add/lockfile_updated/out/Cargo.lock | 2 +- .../cargo_info/not_found/out/Cargo.lock | 2 +- .../cargo_info/path_dependency/in/Cargo.lock | 2 +- .../cargo_info/path_dependency/out/Cargo.lock | 2 +- .../out/Cargo.lock | 2 +- .../out/Cargo.lock | 2 +- .../with_frozen_within_ws/out/Cargo.lock | 2 +- .../with_locked_within_ws/out/Cargo.lock | 2 +- .../cargo_info/within_workspace.in/Cargo.lock | 2 +- .../cargo_info/within_ws/out/Cargo.lock | 2 +- .../in/Cargo.lock | 2 +- .../out/Cargo.lock | 2 +- .../out/Cargo.lock | 2 +- .../within_ws_without_lockfile/out/Cargo.lock | 2 +- .../in/Cargo.lock | 2 +- .../out/Cargo.lock | 2 +- .../cargo_remove/gc_patch/out/Cargo.lock | 2 +- .../update_lock_file/in/Cargo.lock | 2 +- .../update_lock_file/out/Cargo.lock | 2 +- tests/testsuite/git.rs | 2 +- tests/testsuite/lockfile_compat.rs | 54 +++++-------------- tests/testsuite/lockfile_path.rs | 2 +- tests/testsuite/package.rs | 10 ++-- tests/testsuite/publish.rs | 2 +- 32 files changed, 52 insertions(+), 90 deletions(-) diff --git a/src/cargo/core/resolver/resolve.rs b/src/cargo/core/resolver/resolve.rs index 2da7fd5c2176..ca3ee43a2ba7 100644 --- a/src/cargo/core/resolver/resolve.rs +++ b/src/cargo/core/resolver/resolve.rs @@ -84,13 +84,14 @@ pub enum ResolveVersion { /// branch specifiers. /// /// * Introduced in 2020 in version 1.47. - /// * New lockfiles use V3 by default starting in 1.53. + /// * New lockfiles use V3 by default from in 1.53 to 1.82. V3, /// SourceId URL serialization is aware of URL encoding. For example, /// `?branch=foo bar` is now encoded as `?branch=foo+bar` and can be decoded /// back and forth correctly. /// /// * Introduced in 2024 in version 1.78. + /// * New lockfiles use V4 by default starting in 1.83. V4, /// Unstable. Will collect a certain amount of changes and then go. /// @@ -107,7 +108,7 @@ impl ResolveVersion { /// Update this and the description of enum variants of [`ResolveVersion`] /// when we're changing the default lockfile version. fn default() -> ResolveVersion { - ResolveVersion::V3 + ResolveVersion::V4 } /// The maximum version of lockfile made into the stable channel. @@ -137,7 +138,9 @@ impl ResolveVersion { .unwrap() }; - if rust_version >= &rust(1, 53) { + if rust_version >= &rust(1, 83) { + ResolveVersion::V4 + } else if rust_version >= &rust(1, 53) { ResolveVersion::V3 } else if rust_version >= &rust(1, 41) { ResolveVersion::V2 diff --git a/src/cargo/core/source_id.rs b/src/cargo/core/source_id.rs index 19ec9ca051c2..53eb7f16f7ee 100644 --- a/src/cargo/core/source_id.rs +++ b/src/cargo/core/source_id.rs @@ -644,10 +644,7 @@ impl fmt::Display for SourceId { // Don't replace the URL display for git references, // because those are kind of expected to be URLs. write!(f, "{}", self.inner.url)?; - // TODO(-Znext-lockfile-bump): set it to true when the default is - // lockfile v4, because we want Source ID serialization to be - // consistent with lockfile. - if let Some(pretty) = reference.pretty_ref(false) { + if let Some(pretty) = reference.pretty_ref(true) { write!(f, "?{}", pretty)?; } diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index aa22eb3e4393..7a6cc7851a1b 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -226,12 +226,8 @@ fn ident_shallow(id: &SourceId, is_shallow: bool) -> String { impl<'gctx> Debug for GitSource<'gctx> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "git repo at {}", self.remote.url())?; - - // TODO(-Znext-lockfile-bump): set it to true when the default is - // lockfile v4, because we want Source ID serialization to be - // consistent with lockfile. match &self.locked_rev { - Revision::Deferred(git_ref) => match git_ref.pretty_ref(false) { + Revision::Deferred(git_ref) => match git_ref.pretty_ref(true) { Some(s) => write!(f, " ({})", s), None => Ok(()), }, diff --git a/src/cargo/util/toml_mut/dependency.rs b/src/cargo/util/toml_mut/dependency.rs index b66fc56afbcb..5e0e437e8f65 100644 --- a/src/cargo/util/toml_mut/dependency.rs +++ b/src/cargo/util/toml_mut/dependency.rs @@ -1002,11 +1002,7 @@ impl GitSource { impl std::fmt::Display for GitSource { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let git_ref = self.git_ref(); - - // TODO(-Znext-lockfile-bump): set it to true when the default is - // lockfile v4, because we want Source ID serialization to be - // consistent with lockfile. - if let Some(pretty_ref) = git_ref.pretty_ref(false) { + if let Some(pretty_ref) = git_ref.pretty_ref(true) { write!(f, "{}?{}", self.git, pretty_ref) } else { write!(f, "{}", self.git) diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index cc58f4ef0af9..b001da4f85b7 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -1790,7 +1790,7 @@ fn sparse_lockfile() { str![[r##" # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "a" diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.lock b/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.lock index 8c304c1c338a..b27519688c9d 100644 --- a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.lock +++ b/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "bar" diff --git a/tests/testsuite/cargo_add/locked_unchanged/in/Cargo.lock b/tests/testsuite/cargo_add/locked_unchanged/in/Cargo.lock index b88709a9e9be..bfa9ea207069 100644 --- a/tests/testsuite/cargo_add/locked_unchanged/in/Cargo.lock +++ b/tests/testsuite/cargo_add/locked_unchanged/in/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_add/lockfile_updated/in/Cargo.lock b/tests/testsuite/cargo_add/lockfile_updated/in/Cargo.lock index d8fa962f3069..0b048b97b204 100644 --- a/tests/testsuite/cargo_add/lockfile_updated/in/Cargo.lock +++ b/tests/testsuite/cargo_add/lockfile_updated/in/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_add/lockfile_updated/out/Cargo.lock b/tests/testsuite/cargo_add/lockfile_updated/out/Cargo.lock index e423b3d1f8b7..da62406bdba2 100644 --- a/tests/testsuite/cargo_add/lockfile_updated/out/Cargo.lock +++ b/tests/testsuite/cargo_add/lockfile_updated/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/not_found/out/Cargo.lock b/tests/testsuite/cargo_info/not_found/out/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/not_found/out/Cargo.lock +++ b/tests/testsuite/cargo_info/not_found/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/path_dependency/in/Cargo.lock b/tests/testsuite/cargo_info/path_dependency/in/Cargo.lock index 378b02cf7b7e..4f842c40bfeb 100644 --- a/tests/testsuite/cargo_info/path_dependency/in/Cargo.lock +++ b/tests/testsuite/cargo_info/path_dependency/in/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "crate1" diff --git a/tests/testsuite/cargo_info/path_dependency/out/Cargo.lock b/tests/testsuite/cargo_info/path_dependency/out/Cargo.lock index 378b02cf7b7e..4f842c40bfeb 100644 --- a/tests/testsuite/cargo_info/path_dependency/out/Cargo.lock +++ b/tests/testsuite/cargo_info/path_dependency/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "crate1" diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.lock b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.lock +++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.lock b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.lock +++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.lock b/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.lock +++ b/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.lock b/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.lock +++ b/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/within_workspace.in/Cargo.lock b/tests/testsuite/cargo_info/within_workspace.in/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/within_workspace.in/Cargo.lock +++ b/tests/testsuite/cargo_info/within_workspace.in/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/within_ws/out/Cargo.lock b/tests/testsuite/cargo_info/within_ws/out/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/within_ws/out/Cargo.lock +++ b/tests/testsuite/cargo_info/within_ws/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.lock b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.lock index cf3fed84f810..ac82f516e38c 100644 --- a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.lock +++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.lock b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.lock index cf3fed84f810..ac82f516e38c 100644 --- a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.lock +++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.lock b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.lock +++ b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.lock b/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.lock index 3d372c49933f..58cfa016000b 100644 --- a/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.lock +++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/without_requiring_registry_auth/in/Cargo.lock b/tests/testsuite/cargo_info/without_requiring_registry_auth/in/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/without_requiring_registry_auth/in/Cargo.lock +++ b/tests/testsuite/cargo_info/without_requiring_registry_auth/in/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_info/without_requiring_registry_auth/out/Cargo.lock b/tests/testsuite/cargo_info/without_requiring_registry_auth/out/Cargo.lock index e9ede42b3cb2..f132b5ac5ae9 100644 --- a/tests/testsuite/cargo_info/without_requiring_registry_auth/out/Cargo.lock +++ b/tests/testsuite/cargo_info/without_requiring_registry_auth/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-list-test-fixture" diff --git a/tests/testsuite/cargo_remove/gc_patch/out/Cargo.lock b/tests/testsuite/cargo_remove/gc_patch/out/Cargo.lock index 4a1467ba16d0..518f5a9ab83b 100644 --- a/tests/testsuite/cargo_remove/gc_patch/out/Cargo.lock +++ b/tests/testsuite/cargo_remove/gc_patch/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "bar" diff --git a/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock b/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock index a4018e70eb47..261eef0e8063 100644 --- a/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock +++ b/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-remove-test-fixture" diff --git a/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock b/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock index af60414ddad2..3aa0ca7a5e7b 100644 --- a/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock +++ b/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cargo-remove-test-fixture" diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index acd0d35daaf4..0fd25bf2db08 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -283,7 +283,7 @@ fn cargo_compile_git_dep_pull_request() { .with_stderr_data(str![[r#" [UPDATING] git repository `[ROOTURL]/dep1` [LOCKING] 1 package to latest compatible version -[COMPILING] dep1 v0.5.0 ([ROOTURL]/dep1?rev=refs/pull/330/head#[..]) +[COMPILING] dep1 v0.5.0 ([ROOTURL]/dep1?rev=refs%2Fpull%2F330%2Fhead#[..]) [COMPILING] foo v0.0.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s diff --git a/tests/testsuite/lockfile_compat.rs b/tests/testsuite/lockfile_compat.rs index aa22b0715950..4a24993b1606 100644 --- a/tests/testsuite/lockfile_compat.rs +++ b/tests/testsuite/lockfile_compat.rs @@ -21,7 +21,7 @@ fn oldest_lockfile_still_works_with_command(cargo_command: &str) { let expected_lockfile = str![[r##" # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "bar" @@ -173,7 +173,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" str![[r##" # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "bar" @@ -407,7 +407,7 @@ fn current_lockfile_format() { let expected = str![[r##" # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "bar" @@ -473,7 +473,7 @@ dependencies = [ str![[r##" # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "bar" @@ -682,7 +682,7 @@ dependencies = [ name = "foo" version = "0.0.1" edition = "2015" - authors = [] + rust-version = "1.81" # ensure it stays in lockfile v3 [dependencies] dep1 = {{ git = '{}', branch = 'master' }} @@ -937,38 +937,6 @@ Caused by: .run(); } -#[cargo_test] -fn v4_cannot_be_created_from_scratch() { - let p = project() - .file( - "Cargo.toml", - &format!( - r#" - [package] - name = "foo" - version = "0.0.1" - edition = "2015" - "#, - ), - ) - .file("src/lib.rs", "") - .build(); - - p.cargo("fetch").run(); - - let lockfile = r#"# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "foo" -version = "0.0.1" -"#; - - let lock = p.read_lockfile(); - assert_e2e().eq(&lock, lockfile); -} - fn create_branch(repo: &git2::Repository, branch: &str, head_id: git2::Oid) { repo.branch(branch, &repo.find_commit(head_id).unwrap(), true) .unwrap(); @@ -995,6 +963,7 @@ fn v3_and_git_url_encoded(ref_kind: &str, f: impl FnOnce(&git2::Repository, &str let head_id = repo.head().unwrap().target().unwrap(); // Ref name with special characters let git_ref = "a-_+#$)"; + let encoded_ref = "a-_%2B%23%24%29"; f(&repo, git_ref, head_id); let lockfile = format!( @@ -1025,6 +994,7 @@ dependencies = [ name = "foo" version = "0.0.1" edition = "2015" + rust-version = "1.81" # ensure it stays in lockfile v3 [dependencies] dep1 = {{ git = '{url}', {ref_kind} = '{git_ref}' }} @@ -1040,8 +1010,8 @@ dependencies = [ "\ [UPDATING] git repository `[ROOTURL]/dep1` [LOCKING] 1 package to latest compatible version -[ADDING] dep1 v0.5.0 ([ROOTURL]/dep1?{ref_kind}={git_ref}#[..]) -[CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1?{ref_kind}={git_ref}#[..]) +[ADDING] dep1 v0.5.0 ([ROOTURL]/dep1?{ref_kind}={encoded_ref}#[..]) +[CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1?{ref_kind}={encoded_ref}#[..]) [CHECKING] foo v0.0.1 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s " @@ -1135,8 +1105,8 @@ dependencies = [ "\ [UPDATING] git repository `[ROOTURL]/dep1` [LOCKING] 1 package to latest compatible version -[ADDING] dep1 v0.5.0 ([ROOTURL]/dep1?{ref_kind}={git_ref}#[..]) -[CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1?{ref_kind}={git_ref}#[..]) +[ADDING] dep1 v0.5.0 ([ROOTURL]/dep1?{ref_kind}={encoded_ref}#[..]) +[CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1?{ref_kind}={encoded_ref}#[..]) [CHECKING] foo v0.0.1 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s " @@ -1281,7 +1251,7 @@ dependencies = [ // last version of v3 as the default ("1.82", None, 3), // v4 is the default - ("1.83", None, 3), + ("1.83", None, 4), ("1.83", Some(1), 1), ("1.83", Some(2), 2), ("1.83", Some(3), 3), diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index f7f513859e60..c1b698e402ad 100644 --- a/tests/testsuite/lockfile_path.rs +++ b/tests/testsuite/lockfile_path.rs @@ -441,7 +441,7 @@ fn run_embed() { } const VALID_LOCKFILE: &str = r#"# Test lockfile -version = 3 +version = 4 [[package]] name = "test_foo" diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 1ddc09aa2c36..d5c9ea26eaf0 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -3104,7 +3104,7 @@ path = "src/main.rs" ); let cargo_lock_contents = r#"# This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "foo" @@ -3206,7 +3206,7 @@ path = "src/main.rs" ); let cargo_lock_contents = r#"# This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "foo" @@ -3321,7 +3321,7 @@ path = "src/main.rs" ); let cargo_lock_contents = r#"# This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "foo" @@ -5241,7 +5241,7 @@ fn workspace_with_local_deps_nightly() { let generated_lock = format!( r#"# This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "level1" @@ -5767,7 +5767,7 @@ fn workspace_with_local_deps_alternative_index() { let generated_lock = format!( r#"# This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "level1" diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index 6ddc33989b70..2ee6639743df 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -1606,7 +1606,7 @@ You may press ctrl-c to skip waiting; the crate should be available shortly. // The important check here is that it is 1.0.1 in the registry. "# This file is automatically @generated by Cargo.\n\ # It is not intended for manual editing.\n\ - version = 3\n\ + version = 4\n\ \n\ [[package]]\n\ name = \"dep1\"\n\