Skip to content

Commit

Permalink
Prefer field.workspace = true to field = { workspace = true }
Browse files Browse the repository at this point in the history
  • Loading branch information
Muscraft committed Apr 20, 2022
1 parent edffc4a commit ea79548
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub enum TomlDependency<P: Clone = String> {
/// In the simple format, only a version is specified, eg.
/// `package = "<version>"`
Simple(String),
/// `package = { workspace = true }`
/// `package.workspace = true`
Workspace(TomlWorkspaceDependency),
/// The simple format is equivalent to a detailed dependency
/// specifying only a version, eg.
Expand Down Expand Up @@ -990,7 +990,7 @@ where
deserializer.deserialize_any(Visitor)
}

/// Enum that allows for the parsing of { workspace = true } in a Cargo.toml
/// Enum that allows for the parsing of `field.workspace = true` in a Cargo.toml
///
/// It allows for things to be inherited from a workspace or defined as needed
#[derive(Deserialize, Serialize, Clone, Debug)]
Expand Down
24 changes: 12 additions & 12 deletions src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -1458,16 +1458,16 @@ edition = "2018"
```toml
# in a workspace member's Cargo.toml
[package]
version = { workspace = true }
authors = { workspace = true }
description = { workspace = true }
documentation = { workspace = true }
readme = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
license = { workspace = true }
license-file = { workspace = true }
keywords = { workspace = true }
categories = { workspace = true }
publish = { workspace = true }
version.workspace = true
authors.workspace = true
description.workspace = true
documentation.workspace = true
readme.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
license-file.workspace = true
keywords.workspace = true
categories.workspace = true
publish.workspace = true
```
74 changes: 37 additions & 37 deletions tests/testsuite/inheritable_workspace_fields.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Tests for inheriting Cargo.toml fields with { workspace = true }
//! Tests for inheriting Cargo.toml fields with field.workspace = true
use cargo_test_support::registry::{Dependency, Package};
use cargo_test_support::{
basic_lib_manifest, basic_manifest, git, path2url, paths, project, publish, registry,
Expand Down Expand Up @@ -119,24 +119,24 @@ fn inherit_own_workspace_fields() {
"Cargo.toml",
r#"
cargo-features = ["workspace-inheritance"]
badges = { workspace = true }
badges.workspace = true
[package]
name = "foo"
version = { workspace = true }
authors = { workspace = true }
description = { workspace = true }
documentation = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
license = { workspace = true }
keywords = { workspace = true }
categories = { workspace = true }
publish = { workspace = true }
edition = { workspace = true }
rust-version = { workspace = true }
exclude = { workspace = true }
include = { workspace = true }
version.workspace = true
authors.workspace = true
description.workspace = true
documentation.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true
publish.workspace = true
edition.workspace = true
rust-version.workspace = true
exclude.workspace = true
include.workspace = true
[workspace]
members = []
Expand Down Expand Up @@ -501,7 +501,7 @@ fn inherit_from_own_undefined_field() {
name = "foo"
version = "1.2.5"
authors = ["rustaceans"]
description = { workspace = true }
description.workspace = true
[workspace]
members = []
Expand Down Expand Up @@ -623,27 +623,27 @@ fn inherit_workspace_fields() {
.file(
"bar/Cargo.toml",
r#"
badges = { workspace = true }
badges.workspace = true
cargo-features = ["workspace-inheritance"]
[package]
name = "bar"
workspace = ".."
version = { workspace = true }
authors = { workspace = true }
description = { workspace = true }
documentation = { workspace = true }
readme = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
license = { workspace = true }
license-file = { workspace = true }
keywords = { workspace = true }
categories = { workspace = true }
publish = { workspace = true }
edition = { workspace = true }
rust-version = { workspace = true }
exclude = { workspace = true }
include = { workspace = true }
version.workspace = true
authors.workspace = true
description.workspace = true
documentation.workspace = true
readme.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
license-file.workspace = true
keywords.workspace = true
categories.workspace = true
publish.workspace = true
edition.workspace = true
rust-version.workspace = true
exclude.workspace = true
include.workspace = true
"#,
)
.file("LICENSE", "license")
Expand Down Expand Up @@ -1298,7 +1298,7 @@ fn error_no_root_workspace() {
workspace = ".."
version = "1.2.3"
authors = ["rustaceans"]
description = { workspace = true }
description.workspace = true
"#,
)
.file("src/main.rs", "fn main() {}")
Expand Down Expand Up @@ -1385,7 +1385,7 @@ fn workspace_inheritance_not_enabled() {
name = "foo"
version = "1.2.5"
authors = ["rustaceans"]
description = { workspace = true }
description.workspace = true
[workspace]
members = []
Expand Down Expand Up @@ -1431,7 +1431,7 @@ fn nightly_required() {
name = "foo"
version = "1.2.5"
authors = ["rustaceans"]
description = { workspace = true }
description.workspace = true
[workspace]
members = []
Expand Down

0 comments on commit ea79548

Please sign in to comment.