Prefer field.workspace = true to field = { workspace = true }

This commit is contained in:
Scott Schafer 2022-04-20 10:44:53 -05:00
parent edffc4ada3
commit ea79548c1b
3 changed files with 51 additions and 51 deletions

View File

@ -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.
@ -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)]

View File

@ -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
```

View File

@ -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,
@ -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 = []
@ -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 = []
@ -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")
@ -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() {}")
@ -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 = []
@ -1431,7 +1431,7 @@ fn nightly_required() {
name = "foo"
version = "1.2.5"
authors = ["rustaceans"]
description = { workspace = true }
description.workspace = true
[workspace]
members = []