Skip to content

Commit ea79548

Browse files
committed
Prefer field.workspace = true to field = { workspace = true }
1 parent edffc4a commit ea79548

File tree

3 files changed

+51
-51
lines changed

3 files changed

+51
-51
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub enum TomlDependency<P: Clone = String> {
225225
/// In the simple format, only a version is specified, eg.
226226
/// `package = "<version>"`
227227
Simple(String),
228-
/// `package = { workspace = true }`
228+
/// `package.workspace = true`
229229
Workspace(TomlWorkspaceDependency),
230230
/// The simple format is equivalent to a detailed dependency
231231
/// specifying only a version, eg.
@@ -990,7 +990,7 @@ where
990990
deserializer.deserialize_any(Visitor)
991991
}
992992

993-
/// Enum that allows for the parsing of { workspace = true } in a Cargo.toml
993+
/// Enum that allows for the parsing of `field.workspace = true` in a Cargo.toml
994994
///
995995
/// It allows for things to be inherited from a workspace or defined as needed
996996
#[derive(Deserialize, Serialize, Clone, Debug)]

src/doc/src/reference/unstable.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,16 +1458,16 @@ edition = "2018"
14581458
```toml
14591459
# in a workspace member's Cargo.toml
14601460
[package]
1461-
version = { workspace = true }
1462-
authors = { workspace = true }
1463-
description = { workspace = true }
1464-
documentation = { workspace = true }
1465-
readme = { workspace = true }
1466-
homepage = { workspace = true }
1467-
repository = { workspace = true }
1468-
license = { workspace = true }
1469-
license-file = { workspace = true }
1470-
keywords = { workspace = true }
1471-
categories = { workspace = true }
1472-
publish = { workspace = true }
1461+
version.workspace = true
1462+
authors.workspace = true
1463+
description.workspace = true
1464+
documentation.workspace = true
1465+
readme.workspace = true
1466+
homepage.workspace = true
1467+
repository.workspace = true
1468+
license.workspace = true
1469+
license-file.workspace = true
1470+
keywords.workspace = true
1471+
categories.workspace = true
1472+
publish.workspace = true
14731473
```

tests/testsuite/inheritable_workspace_fields.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Tests for inheriting Cargo.toml fields with { workspace = true }
1+
//! Tests for inheriting Cargo.toml fields with field.workspace = true
22
use cargo_test_support::registry::{Dependency, Package};
33
use cargo_test_support::{
44
basic_lib_manifest, basic_manifest, git, path2url, paths, project, publish, registry,
@@ -119,24 +119,24 @@ fn inherit_own_workspace_fields() {
119119
"Cargo.toml",
120120
r#"
121121
cargo-features = ["workspace-inheritance"]
122-
badges = { workspace = true }
122+
badges.workspace = true
123123
124124
[package]
125125
name = "foo"
126-
version = { workspace = true }
127-
authors = { workspace = true }
128-
description = { workspace = true }
129-
documentation = { workspace = true }
130-
homepage = { workspace = true }
131-
repository = { workspace = true }
132-
license = { workspace = true }
133-
keywords = { workspace = true }
134-
categories = { workspace = true }
135-
publish = { workspace = true }
136-
edition = { workspace = true }
137-
rust-version = { workspace = true }
138-
exclude = { workspace = true }
139-
include = { workspace = true }
126+
version.workspace = true
127+
authors.workspace = true
128+
description.workspace = true
129+
documentation.workspace = true
130+
homepage.workspace = true
131+
repository.workspace = true
132+
license.workspace = true
133+
keywords.workspace = true
134+
categories.workspace = true
135+
publish.workspace = true
136+
edition.workspace = true
137+
rust-version.workspace = true
138+
exclude.workspace = true
139+
include.workspace = true
140140
141141
[workspace]
142142
members = []
@@ -501,7 +501,7 @@ fn inherit_from_own_undefined_field() {
501501
name = "foo"
502502
version = "1.2.5"
503503
authors = ["rustaceans"]
504-
description = { workspace = true }
504+
description.workspace = true
505505
506506
[workspace]
507507
members = []
@@ -623,27 +623,27 @@ fn inherit_workspace_fields() {
623623
.file(
624624
"bar/Cargo.toml",
625625
r#"
626-
badges = { workspace = true }
626+
badges.workspace = true
627627
cargo-features = ["workspace-inheritance"]
628628
[package]
629629
name = "bar"
630630
workspace = ".."
631-
version = { workspace = true }
632-
authors = { workspace = true }
633-
description = { workspace = true }
634-
documentation = { workspace = true }
635-
readme = { workspace = true }
636-
homepage = { workspace = true }
637-
repository = { workspace = true }
638-
license = { workspace = true }
639-
license-file = { workspace = true }
640-
keywords = { workspace = true }
641-
categories = { workspace = true }
642-
publish = { workspace = true }
643-
edition = { workspace = true }
644-
rust-version = { workspace = true }
645-
exclude = { workspace = true }
646-
include = { workspace = true }
631+
version.workspace = true
632+
authors.workspace = true
633+
description.workspace = true
634+
documentation.workspace = true
635+
readme.workspace = true
636+
homepage.workspace = true
637+
repository.workspace = true
638+
license.workspace = true
639+
license-file.workspace = true
640+
keywords.workspace = true
641+
categories.workspace = true
642+
publish.workspace = true
643+
edition.workspace = true
644+
rust-version.workspace = true
645+
exclude.workspace = true
646+
include.workspace = true
647647
"#,
648648
)
649649
.file("LICENSE", "license")
@@ -1298,7 +1298,7 @@ fn error_no_root_workspace() {
12981298
workspace = ".."
12991299
version = "1.2.3"
13001300
authors = ["rustaceans"]
1301-
description = { workspace = true }
1301+
description.workspace = true
13021302
"#,
13031303
)
13041304
.file("src/main.rs", "fn main() {}")
@@ -1385,7 +1385,7 @@ fn workspace_inheritance_not_enabled() {
13851385
name = "foo"
13861386
version = "1.2.5"
13871387
authors = ["rustaceans"]
1388-
description = { workspace = true }
1388+
description.workspace = true
13891389
13901390
[workspace]
13911391
members = []
@@ -1431,7 +1431,7 @@ fn nightly_required() {
14311431
name = "foo"
14321432
version = "1.2.5"
14331433
authors = ["rustaceans"]
1434-
description = { workspace = true }
1434+
description.workspace = true
14351435
14361436
[workspace]
14371437
members = []

0 commit comments

Comments
 (0)