Skip to content

Commit

Permalink
Auto merge of #12302 - ehuss:next-lockfile-error, r=weihanglo
Browse files Browse the repository at this point in the history
-Znext-lockfile-bump: Don't suggest using -Z on stable

This changes the lockfile version 4 error to not suggest using `-Znext-lockfile-bump` on the stable channel. I fear this could be confusing to users when the real version 4 is stabilized, and the user is using a too old version of cargo. Instead this produces the same error message as any unknown version would produce, with a suggestion to update.
  • Loading branch information
bors committed Jun 22, 2023
2 parents bda23fc + 604c8f8 commit 5e842cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cargo/core/resolver/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ impl EncodableResolve {
let mut checksums = HashMap::new();

let mut version = match self.version {
Some(4) => {
Some(4) if ws.config().nightly_features_allowed => {
if unstable_lockfile_version_allowed {
ResolveVersion::V4
} else {
anyhow::bail!("lock file version 4 requires `-Znext-lockfile-bump`",)
anyhow::bail!("lock file version 4 requires `-Znext-lockfile-bump`");
}
}
Some(3) => ResolveVersion::V3,
Expand Down
15 changes: 15 additions & 0 deletions tests/testsuite/lockfile_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,21 @@ fn v4_is_unstable() {
"\
error: failed to parse lock file at: [CWD]/Cargo.lock
Caused by:
lock file version `4` was found, but this version of Cargo does not \
understand this lock file, perhaps Cargo needs to be updated?
",
)
.run();

// On nightly, let the user know about the `-Z` flag.
p.cargo("fetch")
.masquerade_as_nightly_cargo(&["-Znext-lockfile-bump"])
.with_status(101)
.with_stderr(
"\
error: failed to parse lock file at: [CWD]/Cargo.lock
Caused by:
lock file version 4 requires `-Znext-lockfile-bump`
",
Expand Down

0 comments on commit 5e842cc

Please sign in to comment.