Skip to content

Commit 8181bc8

Browse files
committed
refactor(toml): Delay project warnings until Edition is parsed
1 parent b9d913e commit 8181bc8

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -935,26 +935,9 @@ fn to_real_manifest(
935935
);
936936
};
937937

938-
let original_package = match (&original_toml.package, &original_toml.project) {
939-
(Some(_), Some(project)) => {
940-
warnings.push(format!(
941-
"manifest at `{}` contains both `project` and `package`, \
942-
this could become a hard error in the future",
943-
package_root.display()
944-
));
945-
project.clone()
946-
}
947-
(Some(package), None) => package.clone(),
948-
(None, Some(project)) => {
949-
warnings.push(format!(
950-
"manifest at `{}` contains `[project]` instead of `[package]`, \
951-
this could become a hard error in the future",
952-
package_root.display()
953-
));
954-
project.clone()
955-
}
956-
(None, None) => bail!("no `package` section found"),
957-
};
938+
let original_package = original_toml
939+
.package()
940+
.ok_or_else(|| anyhow::format_err!("no `package` section found"))?;
958941

959942
let package_name = &original_package.name;
960943
if package_name.contains(':') {
@@ -1044,6 +1027,24 @@ fn to_real_manifest(
10441027
)));
10451028
}
10461029

1030+
match (&original_toml.package, &original_toml.project) {
1031+
(Some(_), Some(_)) => {
1032+
warnings.push(format!(
1033+
"manifest at `{}` contains both `project` and `package`, \
1034+
this could become a hard error in the future",
1035+
package_root.display()
1036+
));
1037+
}
1038+
(None, Some(_)) => {
1039+
warnings.push(format!(
1040+
"manifest at `{}` contains `[project]` instead of `[package]`, \
1041+
this could become a hard error in the future",
1042+
package_root.display()
1043+
));
1044+
}
1045+
(Some(_), None) | (None, None) => {}
1046+
}
1047+
10471048
if resolved_package.metabuild.is_some() {
10481049
features.require(Feature::metabuild())?;
10491050
}

0 commit comments

Comments
 (0)