@@ -1233,63 +1233,148 @@ cargo check -Z unstable-options -Z check-cfg-well-known-values
12331233* RFC: [ #2906 ] ( https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md )
12341234* Tracking Issue: [ #8415 ] ( https://github.com/rust-lang/cargo/issues/8415 )
12351235
1236- The ` workspace-inheritance ` feature allows workspace members to inherit fields
1237- and dependencies from a workspace.
1236+ ### The ` workspace.package ` table
12381237
1239- Example 1:
1238+ * Stabilization* : This would be in [ ` workspaces.md ` ] [ workspaces ] , under
1239+ [ The ` workspace.metadata ` table] [ workspace-metadata-table ]
12401240
1241- ``` toml
1242- # in workspace's Cargo.toml
1243- [workspace .dependencies ]
1244- log = " 0.3.1"
1245- log2 = { version = " 2.0.0" , package = " log" }
1246- serde = { git = ' https://github.com/serde-rs/serde' }
1247- wasm-bindgen-cli = { path = " crates/cli" }
1248- ```
1241+ The ` workspace.package ` table is where you define keys that can be
1242+ inherited by members of a workspace. These keys can be inherited by
1243+ defining them in the member package with ` {key}.workspace = true ` .
12491244
1250- ``` toml
1251- # in a workspace member's Cargo.toml
1252- [dependencies ]
1253- log.workspace = true
1254- log2.workspace = true
1255- ```
1245+ Keys that are supported:
1246+
1247+ | | |
1248+ | ----------------| -----------------|
1249+ | ` authors ` | ` categories ` |
1250+ | ` description ` | ` documentation ` |
1251+ | ` edition ` | ` exclude ` |
1252+ | ` homepage ` | ` include ` |
1253+ | ` keywords ` | ` license ` |
1254+ | ` license-file ` | ` publish ` |
1255+ | ` readme ` | ` repository ` |
1256+ | ` rust-version ` | ` version ` |
12561257
1257- Example 2:
1258+ - ` license-file ` and ` readme ` are relative to the workspace root
1259+ - ` include ` and ` exclude ` are relative to your package root
1260+
1261+ Example:
12581262``` toml
1259- # in workspace's Cargo.toml
1263+ # [PROGECT_DIR]/Cargo.toml
1264+ [workspace ]
1265+ memebers = [" bar" ]
1266+
12601267[workspace .package ]
12611268version = " 1.2.3"
12621269authors = [" Nice Folks" ]
12631270description = " ..."
12641271documentation = " https://example.github.io/example"
1265- readme = " README.md"
1266- homepage = " https://example.com"
1267- repository = " https://github.com/example/example"
1268- license = " MIT"
1269- license-file = " ./LICENSE"
1270- keywords = [" cli" ]
1271- categories = [" development-tools" ]
1272- publish = false
1273- edition = " 2018"
12741272```
12751273
12761274``` toml
1277- # in a workspace member's Cargo.toml
1275+ # [PROGECT_DIR]/bar/ Cargo.toml
12781276[package ]
1277+ name = " bar"
12791278version.workspace = true
12801279authors.workspace = true
12811280description.workspace = true
12821281documentation.workspace = true
1283- readme.workspace = true
1284- homepage.workspace = true
1285- repository.workspace = true
1286- license.workspace = true
1287- license-file.workspace = true
1288- keywords.workspace = true
1289- categories.workspace = true
1290- publish.workspace = true
12911282```
12921283
1284+
1285+ ### The ` workspace.dependencies ` table
1286+
1287+ The ` workspace.dependencies ` table is where you define dependencies to be
1288+ inherited by members of a workspace.
1289+
1290+ Specifying a workspace dependency is similar to [ package dependencies] [ specifying-dependencies ] except:
1291+ - Dependencies from this table cannot be declared as ` optional `
1292+ - [ ` features ` ] [ features ] declared in this table are additive with the ` features ` from ` [dependencies] `
1293+
1294+ You can then [ inherit the workspace dependency as a package dependency] [ inheriting-a-dependency-from-a-workspace ]
1295+
1296+ Example:
1297+ ``` toml
1298+ # [PROGECT_DIR]/Cargo.toml
1299+ [workspace ]
1300+ memebers = [" bar" ]
1301+
1302+ [workspace .dependencies ]
1303+ dep = { version = " 0.1" , features = [" fancy" ] }
1304+ dep-build = " 0.8"
1305+ dep-dev = " 0.5.2"
1306+ ```
1307+
1308+ ``` toml
1309+ # [PROGECT_DIR]/bar/Cargo.toml
1310+ [project ]
1311+ name = " bar"
1312+ version = " 0.2.0"
1313+
1314+ [dependencies ]
1315+ dep = { workspace = true , features = [" dancy" ] }
1316+
1317+ [build-dependencies ]
1318+ dep-build.workspace = true
1319+
1320+ [dev-dependencies ]
1321+ dep-dev.workspace = true
1322+ ```
1323+
1324+ [ inheriting-a-dependency-from-a-workspace ] : #inheriting-a-dependency-from-a-workspace
1325+ [ workspace-metadata-table ] : workspaces.md#the-workspacemetadata-table
1326+ [ workspaces ] : workspaces.md
1327+
1328+
1329+ ### Inheriting a dependency from a workspace
1330+
1331+ * Stabilization* : This would be in [ ` specifying-dependencies.md ` ] [ specifying-dependencies ] ,
1332+ under [ Renaming dependencies in Cargo.toml] [ renaming-dependencies-in-cargotoml ]
1333+
1334+ Dependencies can be inherited from a workspace by specifying the
1335+ dependency in the workspace's [ ` [workspace.dependencies] ` ] [ workspace.dependencies ] table.
1336+ After that add it to the ` [dependencies] ` table with ` dep.workspace = true ` .
1337+
1338+ The ` workspace ` key can be defined with:
1339+ - [ ` optional ` ] [ optional ] : Note that the` [workspace.dependencies] ` table is not allowed to specify ` optional ` .
1340+ - [ ` features ` ] [ features ] : These are additive with the features declared in the ` [workspace.dependencies] `
1341+
1342+ The ` workspace ` key cannot be defined with:
1343+
1344+ | | |
1345+ | ------------------| --------------------|
1346+ | ` branch ` | ` default-features ` |
1347+ | ` git ` | ` package ` |
1348+ | ` path ` | ` registry ` |
1349+ | ` registry-index ` | ` rev ` |
1350+ | ` tag ` | ` version ` |
1351+
1352+
1353+ Dependencies in the ` [dependencies] ` , ` [dev-dependencies] ` , ` [build-dependencies] ` , and
1354+ ` [target."...".dependencies] ` sections support the ability to reference the
1355+ ` [workspace.dependencies] ` definition of dependencies.
1356+
1357+ Example:
1358+ ``` toml
1359+ [dependencies ]
1360+ dep.workspace = true
1361+ dep2 = { workspace = true , features = [" fancy" ] }
1362+ dep3 = { workspace = true , optional = true }
1363+ dep4 = { workspace = true , optional = true , features = [" fancy" ] }
1364+
1365+ [build-dependencies ]
1366+ dep-build.workspace = true
1367+
1368+ [dev-dependencies ]
1369+ dep-dev.workspace = true
1370+ ```
1371+
1372+ [ features ] : features.md
1373+ [ optional ] : features.md#optional-dependencies
1374+ [ workspace.dependencies ] : #the-workspacedependencies-table
1375+ [ specifying-dependencies ] : specifying-dependencies.md
1376+ [ renaming-dependencies-in-cargotoml ] : specifying-dependencies.md#renaming-dependencies-in-cargotoml
1377+
12931378## Stabilized and removed features
12941379
12951380### Compile progress
0 commit comments