diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 088dd0196ad2..001b1bc74e40 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -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`") diff --git a/tests/testsuite/edition.rs b/tests/testsuite/edition.rs index e4c66bf21a7c..04c43b383273 100644 --- a/tests/testsuite/edition.rs +++ b/tests/testsuite/edition.rs @@ -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] [..]