Skip to content

Commit 97a4003

Browse files
committed
fix(toml): Warn when edition is unuset, even when MSRV is unset
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.
1 parent fdae9f2 commit 97a4003

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/cargo/util/toml/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1154,8 +1154,8 @@ fn to_real_manifest(
11541154
// so if they can't use a new edition, don't bother to tell them to set it.
11551155
// This also avoids having to worry about whether `package.edition` is compatible with
11561156
// their MSRV.
1157-
if msrv_edition != default_edition {
1158-
let tip = if msrv_edition == latest_edition {
1157+
if msrv_edition != default_edition || rust_version.is_none() {
1158+
let tip = if msrv_edition == latest_edition || rust_version.is_none() {
11591159
format!(" while the latest is {latest_edition}")
11601160
} else {
11611161
format!(" while {msrv_edition} is compatible with `rust-version`")

tests/testsuite/edition.rs

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ fn unset_edition_with_unset_rust_version() {
142142
p.cargo("check -v")
143143
.with_stderr(
144144
"\
145+
[WARNING] no edition set: defaulting to the 2015 edition while the latest is 2021
145146
[CHECKING] foo [..]
146147
[RUNNING] `rustc [..] --edition=2015 [..]`
147148
[FINISHED] [..]

0 commit comments

Comments
 (0)