Skip to content

Commit

Permalink
fix(toml): Warn when edition is unuset, even when MSRV is unset
Browse files Browse the repository at this point in the history
This came up in #14108.  This got overlooked when we added the MSRV
limits to the warning.

Users can silience this by setting a very old MSRV.
I didn't bother finding a way to word a specialized message for this.
Wording for this case seemed hard and I figure someone in this situation
knows how to resolve it.
Instead, we are targeting the majority of users who aren't setting a
`package.rust-version` in the first place.
  • Loading branch information
epage committed Jun 19, 2024
1 parent fdae9f2 commit 97a4003
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,8 +1154,8 @@ fn to_real_manifest(
// so if they can't use a new edition, don't bother to tell them to set it.
// This also avoids having to worry about whether `package.edition` is compatible with
// their MSRV.
if msrv_edition != default_edition {
let tip = if msrv_edition == latest_edition {
if msrv_edition != default_edition || rust_version.is_none() {
let tip = if msrv_edition == latest_edition || rust_version.is_none() {
format!(" while the latest is {latest_edition}")
} else {
format!(" while {msrv_edition} is compatible with `rust-version`")
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ fn unset_edition_with_unset_rust_version() {
p.cargo("check -v")
.with_stderr(
"\
[WARNING] no edition set: defaulting to the 2015 edition while the latest is 2021
[CHECKING] foo [..]
[RUNNING] `rustc [..] --edition=2015 [..]`
[FINISHED] [..]
Expand Down

0 comments on commit 97a4003

Please sign in to comment.