Skip to content

Commit 380be40

Browse files
committed
Allow '.' in workspace.default-members in non-virtual workspaces.
1 parent 92ff479 commit 380be40

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/cargo/core/workspace.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,9 @@ impl<'cfg> Workspace<'cfg> {
690690
for path in default {
691691
let normalized_path = paths::normalize_path(&path);
692692
let manifest_path = normalized_path.join("Cargo.toml");
693-
if !self.members.contains(&manifest_path) {
693+
if !self.members.contains(&manifest_path)
694+
&& (self.is_virtual() || manifest_path != root_manifest_path)
695+
{
694696
// default-members are allowed to be excluded, but they
695697
// still must be referred to by the original (unfiltered)
696698
// members list. Note that we aren't testing against the

tests/testsuite/workspaces.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,35 @@ fn non_virtual_default_members_build_other_member() {
119119
.run();
120120
}
121121

122+
#[cargo_test]
123+
fn non_virtual_default_members_build_root_project() {
124+
let p = project()
125+
.file(
126+
"Cargo.toml",
127+
r#"
128+
[project]
129+
name = "foo"
130+
version = "0.1.0"
131+
authors = []
132+
133+
[workspace]
134+
members = ["bar"]
135+
default-members = ["."]
136+
"#,
137+
)
138+
.file("src/main.rs", "fn main() {}")
139+
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
140+
.file("bar/src/lib.rs", "pub fn bar() {}")
141+
.build();
142+
143+
p.cargo("build")
144+
.with_stderr(
145+
"[..] Compiling foo v0.1.0 ([..])\n\
146+
[..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n",
147+
)
148+
.run();
149+
}
150+
122151
#[cargo_test]
123152
fn inferred_root() {
124153
let p = project()

0 commit comments

Comments
 (0)