From fc200e4a0120d1fe60eac443cf859590f24a1678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Zwoli=C5=84ski?= Date: Fri, 21 Jul 2023 15:19:59 +0200 Subject: [PATCH 1/4] 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 the 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. --- src/doc/src/reference/workspaces.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/doc/src/reference/workspaces.md b/src/doc/src/reference/workspaces.md index 5104a18a3d8..288872032ed 100644 --- a/src/doc/src/reference/workspaces.md +++ b/src/doc/src/reference/workspaces.md @@ -39,6 +39,9 @@ To create a workspace, you add the `[workspace]` table to a `Cargo.toml`: At minimum, a workspace has to have a member, either with a root package or as a virtual manifest. +It's also a good practice to specify the `resolver = "2"` unless it is necessary +to rely on the old one. It is a default resolver for all packages in the `2021` edition +but it has to be explicitely set under the workspace. #### Root package @@ -49,6 +52,7 @@ where the workspace's `Cargo.toml` is located. ```toml [workspace] +resolver = "2" [package] name = "hello_world" # the name of the package @@ -67,6 +71,7 @@ you want to keep all the packages organized in separate directories. # [PROJECT_DIR]/Cargo.toml [workspace] members = ["hello_world"] +resolver = "2" ``` ```toml @@ -86,6 +91,7 @@ the workspace: [workspace] members = ["member1", "path/to/member2", "crates/*"] exclude = ["crates/foo", "path/to/other"] +resolver = "2" ``` All [`path` dependencies] residing in the workspace directory automatically @@ -127,6 +133,7 @@ used: [workspace] members = ["path/to/member1", "path/to/member2", "path/to/member3/*"] default-members = ["path/to/member2", "path/to/member3/foo"] +resolver = "2" ``` When specified, `default-members` must expand to a subset of `members`. @@ -158,6 +165,7 @@ Example: # [PROJECT_DIR]/Cargo.toml [workspace] members = ["bar"] +resolver = "2" [workspace.package] version = "1.2.3" @@ -192,6 +200,7 @@ Example: # [PROJECT_DIR]/Cargo.toml [workspace] members = ["bar"] +resolver = "2" [workspace.dependencies] cc = "1.0.73" @@ -224,6 +233,7 @@ configuration in `Cargo.toml`. For example: ```toml [workspace] members = ["member1", "member2"] +resolver = "2" [workspace.metadata.webcontents] root = "path/to/webproject" From ca89fafa91a0dbd53d19e7f800de444ccc9b1487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Zwoli=C5=84ski?= Date: Tue, 25 Jul 2023 23:55:27 +0200 Subject: [PATCH 2/4] move the guideline under virtual manifest section --- src/doc/src/reference/workspaces.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/doc/src/reference/workspaces.md b/src/doc/src/reference/workspaces.md index 288872032ed..359efcedccc 100644 --- a/src/doc/src/reference/workspaces.md +++ b/src/doc/src/reference/workspaces.md @@ -39,9 +39,6 @@ To create a workspace, you add the `[workspace]` table to a `Cargo.toml`: At minimum, a workspace has to have a member, either with a root package or as a virtual manifest. -It's also a good practice to specify the `resolver = "2"` unless it is necessary -to rely on the old one. It is a default resolver for all packages in the `2021` edition -but it has to be explicitely set under the workspace. #### Root package @@ -79,9 +76,15 @@ resolver = "2" [package] name = "hello_world" # the name of the package version = "0.1.0" # the current version, obeying semver +edition = "2021" # the edition, will have no effect on a resolver used in the workspace authors = ["Alice ", "Bob "] ``` +Note that in a virtual manifest the [`resolver = "2"`](resolver.md#resolver-versions) +should be specified manually. It is usually deduced from the [`package.edition`][package-edition] +field which is absent in virtual manifests and the edition field of a member +won't affect the resolver used by the workspace. + ### The `members` and `exclude` fields The `members` and `exclude` fields define which packages are members of @@ -251,6 +254,7 @@ if that makes sense for the tool in question. [package]: manifest.md#the-package-section [`Cargo.lock`]: ../guide/cargo-toml-vs-cargo-lock.md [package-metadata]: manifest.md#the-metadata-table +[package-edition]: manifest.md#the-edition-field [output directory]: ../guide/build-cache.md [patch]: overriding-dependencies.md#the-patch-section [replace]: overriding-dependencies.md#the-replace-section From f03b762f3126411b5d6b3281370fe8d39eaa3bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Zwoli=C5=84ski?= Date: Tue, 25 Jul 2023 23:55:53 +0200 Subject: [PATCH 3/4] Remove the resolver from all other examples --- src/doc/src/reference/workspaces.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/doc/src/reference/workspaces.md b/src/doc/src/reference/workspaces.md index 359efcedccc..ff6129410e5 100644 --- a/src/doc/src/reference/workspaces.md +++ b/src/doc/src/reference/workspaces.md @@ -94,7 +94,6 @@ the workspace: [workspace] members = ["member1", "path/to/member2", "crates/*"] exclude = ["crates/foo", "path/to/other"] -resolver = "2" ``` All [`path` dependencies] residing in the workspace directory automatically @@ -136,7 +135,6 @@ used: [workspace] members = ["path/to/member1", "path/to/member2", "path/to/member3/*"] default-members = ["path/to/member2", "path/to/member3/foo"] -resolver = "2" ``` When specified, `default-members` must expand to a subset of `members`. @@ -168,7 +166,6 @@ Example: # [PROJECT_DIR]/Cargo.toml [workspace] members = ["bar"] -resolver = "2" [workspace.package] version = "1.2.3" @@ -203,7 +200,6 @@ Example: # [PROJECT_DIR]/Cargo.toml [workspace] members = ["bar"] -resolver = "2" [workspace.dependencies] cc = "1.0.73" @@ -236,7 +232,6 @@ configuration in `Cargo.toml`. For example: ```toml [workspace] members = ["member1", "member2"] -resolver = "2" [workspace.metadata.webcontents] root = "path/to/webproject" From ddfa20b20824f75d75163e9883ff32e37de768fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Zwoli=C5=84ski?= Date: Wed, 26 Jul 2023 17:15:13 +0200 Subject: [PATCH 4/4] Remove last resolver leftover --- src/doc/src/reference/workspaces.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doc/src/reference/workspaces.md b/src/doc/src/reference/workspaces.md index ff6129410e5..36a2e73238e 100644 --- a/src/doc/src/reference/workspaces.md +++ b/src/doc/src/reference/workspaces.md @@ -49,7 +49,6 @@ where the workspace's `Cargo.toml` is located. ```toml [workspace] -resolver = "2" [package] name = "hello_world" # the name of the package