Skip to content

Commit 263d24b

Browse files
committed
Auto merge of #12388 - zvolin:docs-workspace-resolver, r=epage
docs: raise awareness of resolver used inside workspace Workspaces by default use the resolver in version 1. It's been some time already since the 2021 edition which made version 2 a default for alone packages, but yet most of the projects that make a use of the workspaces still depends on an old resolver. By being explicit about the resolver tag inside the workspace we can lower the usage of older resolver for the new projects. This can raise the awareness of this behavior and prevent issues like #12387. I also wasn't aware of this behavior before while not being so new to Rust, and we have the resolver 2 for good reasons, so I think we should be more explicit about it in the documentation. When someone looks for the 'how to make cargo workspace' answers, he's unlikely to get to the `Dependency Resolution` section at the same time, he'll likely just copy paste the workspace example from the `Workspaces` and call it a day, yet extending the usage of an old resolver and not benefiting from the new one.
2 parents 54dfa98 + ddfa20b commit 263d24b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/doc/src/reference/workspaces.md

+8
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,23 @@ you want to keep all the packages organized in separate directories.
6767
# [PROJECT_DIR]/Cargo.toml
6868
[workspace]
6969
members = ["hello_world"]
70+
resolver = "2"
7071
```
7172

7273
```toml
7374
# [PROJECT_DIR]/hello_world/Cargo.toml
7475
[package]
7576
name = "hello_world" # the name of the package
7677
version = "0.1.0" # the current version, obeying semver
78+
edition = "2021" # the edition, will have no effect on a resolver used in the workspace
7779
authors = ["Alice <[email protected]>", "Bob <[email protected]>"]
7880
```
7981

82+
Note that in a virtual manifest the [`resolver = "2"`](resolver.md#resolver-versions)
83+
should be specified manually. It is usually deduced from the [`package.edition`][package-edition]
84+
field which is absent in virtual manifests and the edition field of a member
85+
won't affect the resolver used by the workspace.
86+
8087
### The `members` and `exclude` fields
8188

8289
The `members` and `exclude` fields define which packages are members of
@@ -241,6 +248,7 @@ if that makes sense for the tool in question.
241248
[package]: manifest.md#the-package-section
242249
[`Cargo.lock`]: ../guide/cargo-toml-vs-cargo-lock.md
243250
[package-metadata]: manifest.md#the-metadata-table
251+
[package-edition]: manifest.md#the-edition-field
244252
[output directory]: ../guide/build-cache.md
245253
[patch]: overriding-dependencies.md#the-patch-section
246254
[replace]: overriding-dependencies.md#the-replace-section

0 commit comments

Comments
 (0)