Skip to content

Commit 5e842cc

Browse files
committed
Auto merge of #12302 - ehuss:next-lockfile-error, r=weihanglo
-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.
2 parents bda23fc + 604c8f8 commit 5e842cc

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/cargo/core/resolver/encode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ impl EncodableResolve {
159159
let mut checksums = HashMap::new();
160160

161161
let mut version = match self.version {
162-
Some(4) => {
162+
Some(4) if ws.config().nightly_features_allowed => {
163163
if unstable_lockfile_version_allowed {
164164
ResolveVersion::V4
165165
} else {
166-
anyhow::bail!("lock file version 4 requires `-Znext-lockfile-bump`",)
166+
anyhow::bail!("lock file version 4 requires `-Znext-lockfile-bump`");
167167
}
168168
}
169169
Some(3) => ResolveVersion::V3,

tests/testsuite/lockfile_compat.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,21 @@ fn v4_is_unstable() {
912912
"\
913913
error: failed to parse lock file at: [CWD]/Cargo.lock
914914
915+
Caused by:
916+
lock file version `4` was found, but this version of Cargo does not \
917+
understand this lock file, perhaps Cargo needs to be updated?
918+
",
919+
)
920+
.run();
921+
922+
// On nightly, let the user know about the `-Z` flag.
923+
p.cargo("fetch")
924+
.masquerade_as_nightly_cargo(&["-Znext-lockfile-bump"])
925+
.with_status(101)
926+
.with_stderr(
927+
"\
928+
error: failed to parse lock file at: [CWD]/Cargo.lock
929+
915930
Caused by:
916931
lock file version 4 requires `-Znext-lockfile-bump`
917932
",

0 commit comments

Comments
 (0)