Skip to content

Commit 4d2c0c6

Browse files
committed
fix: Don't add the new package to workspace.members if there is no existing workspace in Cargo.toml.
1 parent f54674a commit 4d2c0c6

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

src/cargo/ops/cargo_new.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::io::{BufRead, BufReader, ErrorKind};
1515
use std::path::{Path, PathBuf};
1616
use std::str::FromStr;
1717
use std::{fmt, slice};
18-
use toml_edit::{Array, Value};
18+
use toml_edit::Value;
1919

2020
#[derive(Clone, Copy, Debug, PartialEq)]
2121
pub enum VersionControl {
@@ -992,11 +992,6 @@ fn update_manifest_with_new_member(
992992
if was_sorted {
993993
members.sort_by(|lhs, rhs| lhs.as_str().cmp(&rhs.as_str()));
994994
}
995-
} else {
996-
let mut array = Array::new();
997-
array.push(display_path);
998-
999-
workspace_document["workspace"]["members"] = toml_edit::value(array);
1000995
}
1001996

1002997
write_atomic(

tests/testsuite/cargo_new/add_lib_into_non_workspace/out/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
workspace = { members = ["bar"] }
21
[package]
32
name = "foo"
43
version = "0.1.0"

0 commit comments

Comments
 (0)