diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 3a091c2e0..020b08d2a 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1028,7 +1028,13 @@ fn to_real_manifest( } if original_toml.project.is_some() { - warnings.push(format!("`[project]` is deprecated in favor of `[package]`")); + if Edition::Edition2024 <= edition { + anyhow::bail!( + "`[project]` is not supported as of the 2024 Edition, please use `[package]`" + ); + } else { + warnings.push(format!("`[project]` is deprecated in favor of `[package]`")); + } } if resolved_package.metabuild.is_some() { diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index 8f79187f8..da8239fd7 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -1005,6 +1005,37 @@ fn warn_manifest_with_project() { .run(); } +#[cargo_test(nightly, reason = "edition2024")] +fn error_manifest_with_project_on_2024() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["edition2024"] + + [project] + name = "foo" + version = "0.0.1" + edition = "2024" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("check") + .masquerade_as_nightly_cargo(&["edition2024"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + +Caused by: + `[project]` is not supported as of the 2024 Edition, please use `[package]` +", + ) + .run(); +} + #[cargo_test] fn warn_manifest_package_and_project() { let p = project()