Skip to content

Commit 2f4d3df

Browse files
committed
fix(toml): Error on use of [project] on 2024 Edition
1 parent c9325c9 commit 2f4d3df

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,13 @@ fn to_real_manifest(
10281028
}
10291029

10301030
if original_toml.project.is_some() {
1031-
warnings.push(format!("`[project]` is deprecated in favor of `[package]`"));
1031+
if Edition::Edition2024 <= edition {
1032+
anyhow::bail!(
1033+
"`[project]` is not supported as of the 2024 Edition, please use `[package]`"
1034+
);
1035+
} else {
1036+
warnings.push(format!("`[project]` is deprecated in favor of `[package]`"));
1037+
}
10321038
}
10331039

10341040
if resolved_package.metabuild.is_some() {

tests/testsuite/check.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,37 @@ fn warn_manifest_with_project() {
10051005
.run();
10061006
}
10071007

1008+
#[cargo_test(nightly, reason = "edition2024")]
1009+
fn error_manifest_with_project_on_2024() {
1010+
let p = project()
1011+
.file(
1012+
"Cargo.toml",
1013+
r#"
1014+
cargo-features = ["edition2024"]
1015+
1016+
[project]
1017+
name = "foo"
1018+
version = "0.0.1"
1019+
edition = "2024"
1020+
"#,
1021+
)
1022+
.file("src/main.rs", "fn main() {}")
1023+
.build();
1024+
1025+
p.cargo("check")
1026+
.masquerade_as_nightly_cargo(&["edition2024"])
1027+
.with_status(101)
1028+
.with_stderr(
1029+
"\
1030+
[ERROR] failed to parse manifest at `[CWD]/Cargo.toml`
1031+
1032+
Caused by:
1033+
`[project]` is not supported as of the 2024 Edition, please use `[package]`
1034+
",
1035+
)
1036+
.run();
1037+
}
1038+
10081039
#[cargo_test]
10091040
fn warn_manifest_package_and_project() {
10101041
let p = project()

0 commit comments

Comments
 (0)