diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 088dd0196ad..001b1bc74e4 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/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index 22d35f781c8..261aa447d83 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -1544,6 +1544,7 @@ fn artifact_dep_target_specified() { version = "0.0.0" authors = [] resolver = "2" + edition = "2015" [dependencies] bindep = { path = "bindep", artifact = "bin", target = "$TARGET" } diff --git a/tests/testsuite/edition.rs b/tests/testsuite/edition.rs index e6d492232b5..04c43b38327 100644 --- a/tests/testsuite/edition.rs +++ b/tests/testsuite/edition.rs @@ -125,6 +125,32 @@ fn edition_unstable() { .run(); } +#[cargo_test] +fn unset_edition_with_unset_rust_version() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = 'foo' + version = '0.1.0' + "#, + ) + .file("src/lib.rs", "") + .build(); + + 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] [..] +", + ) + .run(); +} + #[cargo_test] fn unset_edition_works_with_no_newer_compatible_edition() { let p = project() diff --git a/tests/testsuite/shell_quoting.rs b/tests/testsuite/shell_quoting.rs index 80c4ea44698..bd4355fdab5 100644 --- a/tests/testsuite/shell_quoting.rs +++ b/tests/testsuite/shell_quoting.rs @@ -15,6 +15,7 @@ fn features_are_quoted() { name = "foo" version = "0.1.0" authors = ["mikeyhew@example.com"] + edition = "2015" [features] some_feature = []