Skip to content

Commit a197ec7

Browse files
committed
Don't throw an error when there is no features in Cargo.toml
Because this could happen if the Cargo.toml is "normalized". Instead, show a note in the documentation Fixes #20
1 parent bfbb38a commit a197ec7

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

lib.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ fn process_toml(cargo_toml: &str, args: &Args) -> Result<String, String> {
359359
return Err("Found comment not associated with a feature".into());
360360
}
361361
if features.is_empty() {
362-
return Err("Could not find documented features in Cargo.toml".into());
362+
return Ok("*No documented features in Cargo.toml*".into());
363363
}
364364
let mut result = String::new();
365365
for (f, top, comment) in features {
@@ -585,26 +585,30 @@ default = ["feat1", "something_else"]
585585
}
586586

587587
#[test]
588-
fn parse_error1() {
589-
test_error(
588+
fn no_features() {
589+
let r = process_toml(
590590
r#"
591591
[features]
592592
[dependencies]
593593
foo = 4;
594594
"#,
595-
"Could not find documented features",
596-
);
595+
&Args::default(),
596+
)
597+
.unwrap();
598+
assert_eq!(r, "*No documented features in Cargo.toml*");
597599
}
598600

599601
#[test]
600-
fn parse_error2() {
601-
test_error(
602+
fn no_features2() {
603+
let r = process_toml(
602604
r#"
603605
[packages]
604606
[dependencies]
605607
"#,
606-
"Could not find documented features",
607-
);
608+
&Args::default(),
609+
)
610+
.unwrap();
611+
assert_eq!(r, "*No documented features in Cargo.toml*");
608612
}
609613

610614
#[test]

0 commit comments

Comments
 (0)