Skip to content

Commit

Permalink
-Znext-lockfile-bump: Don't suggest using -Z on stable
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Jun 22, 2023
1 parent bda23fc commit 604c8f8
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 604c8f8

Please sign in to comment.