Skip to content

Commit

Permalink
Don't throw an error when there is no features in Cargo.toml
Browse files Browse the repository at this point in the history
Because this could happen if the Cargo.toml is "normalized".
Instead, show a note in the documentation

Fixes #20
  • Loading branch information
ogoffart committed Dec 29, 2023
1 parent bfbb38a commit a197ec7
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ fn process_toml(cargo_toml: &str, args: &Args) -> Result<String, String> {
return Err("Found comment not associated with a feature".into());
}
if features.is_empty() {
return Err("Could not find documented features in Cargo.toml".into());
return Ok("*No documented features in Cargo.toml*".into());
}
let mut result = String::new();
for (f, top, comment) in features {
Expand Down Expand Up @@ -585,26 +585,30 @@ default = ["feat1", "something_else"]
}

#[test]
fn parse_error1() {
test_error(
fn no_features() {
let r = process_toml(
r#"
[features]
[dependencies]
foo = 4;
"#,
"Could not find documented features",
);
&Args::default(),
)
.unwrap();
assert_eq!(r, "*No documented features in Cargo.toml*");
}

#[test]
fn parse_error2() {
test_error(
fn no_features2() {
let r = process_toml(
r#"
[packages]
[dependencies]
"#,
"Could not find documented features",
);
&Args::default(),
)
.unwrap();
assert_eq!(r, "*No documented features in Cargo.toml*");
}

#[test]
Expand Down

0 comments on commit a197ec7

Please sign in to comment.