Skip to content

Commit 12d7818

Browse files
committed
Add features to the default Cargo.toml file
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
1 parent 9765a44 commit 12d7818

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

crates/cargo-test-support/src/registry.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,30 @@ impl Package {
15231523
manifest.push_str(&format!("rust-version = \"{}\"", version));
15241524
}
15251525

1526+
if !self.features.is_empty() {
1527+
let features: Vec<String> = self
1528+
.features
1529+
.iter()
1530+
.map(|(feature, features)| {
1531+
if features.is_empty() {
1532+
format!("{} = []", feature)
1533+
} else {
1534+
format!(
1535+
"{} = [{}]",
1536+
feature,
1537+
features
1538+
.iter()
1539+
.map(|s| format!("\"{}\"", s))
1540+
.collect::<Vec<_>>()
1541+
.join(", ")
1542+
)
1543+
}
1544+
})
1545+
.collect();
1546+
1547+
manifest.push_str(&format!("\n[features]\n{}", features.join("\n")));
1548+
}
1549+
15261550
for dep in self.deps.iter() {
15271551
let target = match dep.target {
15281552
None => String::new(),

tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)