diff --git a/src/cargo/core/resolver/resolve.rs b/src/cargo/core/resolver/resolve.rs index c572e27d5e0..ca3ee43a2ba 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. @@ -125,28 +126,23 @@ 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, 83) { + ResolveVersion::V4 + } else 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 diff --git a/src/cargo/core/source_id.rs b/src/cargo/core/source_id.rs index 19ec9ca051c..53eb7f16f7e 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 aa22eb3e439..7a6cc7851a1 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 b66fc56afbc..5e0e437e8f6 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 cc58f4ef0af..b001da4f85b 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 8c304c1c338..b27519688c9 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 b88709a9e9b..bfa9ea20706 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 d8fa962f306..0b048b97b20 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 e423b3d1f8b..da62406bdba 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 e9ede42b3cb..f132b5ac5ae 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 378b02cf7b7..4f842c40bfe 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 378b02cf7b7..4f842c40bfe 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 e9ede42b3cb..f132b5ac5ae 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 e9ede42b3cb..f132b5ac5ae 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 e9ede42b3cb..f132b5ac5ae 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 e9ede42b3cb..f132b5ac5ae 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 e9ede42b3cb..f132b5ac5ae 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 e9ede42b3cb..f132b5ac5ae 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 cf3fed84f81..ac82f516e38 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 cf3fed84f81..ac82f516e38 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 e9ede42b3cb..f132b5ac5ae 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 3d372c49933..58cfa016000 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 e9ede42b3cb..f132b5ac5ae 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 e9ede42b3cb..f132b5ac5ae 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 4a1467ba16d..518f5a9ab83 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 a4018e70eb4..261eef0e806 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 af60414ddad..3aa0ca7a5e7 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 acd0d35daaf..0fd25bf2db0 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 18ec5bc2d8f..4a24993b160 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 " @@ -1175,6 +1145,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 +1248,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, 4), + ("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 +1282,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); diff --git a/tests/testsuite/lockfile_path.rs b/tests/testsuite/lockfile_path.rs index f7f513859e6..c1b698e402a 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 1ddc09aa2c3..d5c9ea26eaf 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 6ddc33989b7..2ee6639743d 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\