Skip to content

Commit e91b58d

Browse files
committed
Auto merge of #13794 - epage:workspace, r=weihanglo
docs(ref): Index differences between virtual / real manifests ### What does this PR try to resolve? For a user to read the reference and to understand when each type of workspace might be right for them, they have to know to also read the section on Package Selection. This reframes the section on needing to set `resolver = "2"` to being about differences when there isn't a root package and extends it to summarize a part of Package Selection, linking out to it. The hope is that this will make it all of the differences more discoverable without retreading too much of the same ground within Reference-style documentation. Part of #13580 ### How should we test and review this PR? ### Additional information r? `@weihanglo`
2 parents cb1123f + 5f5e0fc commit e91b58d

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/doc/src/reference/workspaces.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ edition = "2021" # the edition, will have no effect on a resolver used in th
8080
authors = ["Alice <[email protected]>", "Bob <[email protected]>"]
8181
```
8282

83-
Note that in a virtual manifest the [`resolver = "2"`](resolver.md#resolver-versions)
84-
should be specified manually. It is usually deduced from the [`package.edition`][package-edition]
85-
field which is absent in virtual manifests and the edition field of a member
86-
won't affect the resolver used by the workspace.
83+
By having a workspace without a root package,
84+
85+
- [`resolver`](resolver.md#resolver-versions) must be
86+
set explicitly in virtual workspaces as they have no
87+
[`package.edition`][package-edition] to infer it from
88+
[resolver version](resolver.md#resolver-versions).
89+
- Commands run in the workspace root will run against all workspace
90+
members by default, see [`default-members`](#the-default-members-field).
8791

8892
## The `members` and `exclude` fields
8993

@@ -120,14 +124,12 @@ is not inside a subdirectory of the workspace root.
120124
In a workspace, package-related Cargo commands like [`cargo build`] can use
121125
the `-p` / `--package` or `--workspace` command-line flags to determine which
122126
packages to operate on. If neither of those flags are specified, Cargo will
123-
use the package in the current working directory. If the current directory is
124-
a [virtual workspace](#virtual-workspace), it will apply to all members (as if
125-
`--workspace` were specified on the command-line). See also
126-
[`default-members`](#the-default-members-field).
127+
use the package in the current working directory. However, if the current directory is
128+
a workspace root, the [`default-members`](#the-default-members-field) will be used.
127129

128130
## The `default-members` field
129131

130-
The optional `default-members` key can be specified to set the members to
132+
The `default-members` field specifies paths of [members](#the-members-and-exclude-fields) to
131133
operate on when in the workspace root and the package selection flags are not
132134
used:
133135

@@ -137,7 +139,12 @@ members = ["path/to/member1", "path/to/member2", "path/to/member3/*"]
137139
default-members = ["path/to/member2", "path/to/member3/foo"]
138140
```
139141

140-
When specified, `default-members` must expand to a subset of `members`.
142+
> Note: when a [root package](#root-package) is present,
143+
> you can only operate on it using `--package` and `--workspace` flags.
144+
145+
When unspecified, the [root package](#root-package) will be used.
146+
In the case of a [virtual workspace](#virtual-workspace), all members will be used
147+
(as if `--workspace` were specified on the command-line).
141148

142149
## The `package` table
143150

0 commit comments

Comments
 (0)