Skip to content

Commit 4474dc2

Browse files
committed
fix: Don't add the new package to workspace.members if there is no existing workspace in Cargo.toml.
1 parent 627b2ed commit 4474dc2

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
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"

tests/testsuite/cargo_new/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
mod add_lib_into_non_workspace;
12
mod add_members_to_workspace_format_previous_items;
23
mod add_members_to_workspace_format_sorted;
34
mod add_members_to_workspace_with_absolute_package_path;
@@ -12,4 +13,3 @@ mod inherit_workspace_package_table_with_edition;
1213
mod inherit_workspace_package_table_with_registry;
1314
mod inherit_workspace_package_table_without_version;
1415
mod not_inherit_workspace_package_table_if_not_members;
15-
mod add_lib_into_non_workspace;

0 commit comments

Comments
 (0)