From 94ca87eb05cb8d26bf2cfe58e4c6523ee5c056ba Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Tue, 7 Nov 2023 20:03:35 +0800 Subject: [PATCH] Add test for empty feature name Signed-off-by: hi-rustin --- tests/testsuite/features.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index 236b6f65181f..e44807941d10 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -35,6 +35,37 @@ Caused by: .run(); } +#[cargo_test] +fn empty_feature_name() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [features] + "" = [] + "#, + ) + .file("src/main.rs", "") + .build(); + + p.cargo("check") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[..]` + +Caused by: + feature name cannot be empty +", + ) + .run(); +} + #[cargo_test] fn same_name() { // Feature with the same name as a dependency.