Skip to content

Commit

Permalink
Auto merge of #11135 - Muscraft:remove-ref-to-project, r=weihanglo
Browse files Browse the repository at this point in the history
Reduce references to `[project]` within cargo

There was an issue (#11129) with `[project]` being put in the docs but nothing else stating what `[project]` is. This was an oversight by me when writing the docs as `[project]` is still supported in cargo. [Back in 2014](86b2a2a) `[project]` was [renamed to `[package]`](#3388 (comment)), since then it has kinda sat as something that exists and is supported but not really. I brought this up in a [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/removal.20of.20.60.5Bproject.5D.60), and it was suggested that we could show a warning when `[project]` is used in a manifest of a _top-level_ crate.

To go slightly further than this I tried to change as many references from `[project]` to `[package]` as possible. This should hopefully help with confusion between `[project]` and `[package]` in the future.

This PR also includes a cherry-picked commit from #11131 as it was having issues with bors and fits well with the changes that are being made in this PR.

This should ideally be reviewed commit by commit
  • Loading branch information
bors committed Sep 27, 2022
2 parents f6de921 + 8625d72 commit 928561a
Show file tree
Hide file tree
Showing 45 changed files with 889 additions and 715 deletions.
146 changes: 84 additions & 62 deletions src/cargo/util/toml/mod.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/doc/src/reference/specifying-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ Dependencies in the `[dependencies]`, `[dev-dependencies]`, `[build-dependencies
`[workspace.dependencies]` definition of dependencies.

```toml
[project]
[package]
name = "bar"
version = "0.2.0"

Expand Down
2 changes: 1 addition & 1 deletion src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ The `filename` parameter is only available in the `[[bin]]` section of the manif
```toml
cargo-features = ["different-binary-name"]

[project]
[package]
name = "foo"
version = "0.0.1"

Expand Down
2 changes: 1 addition & 1 deletion src/doc/src/reference/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ regex = { version = "1.6.0", default-features = false, features = ["std"] }

```toml
# [PROJECT_DIR]/bar/Cargo.toml
[project]
[package]
name = "bar"
version = "0.2.0"

Expand Down
28 changes: 14 additions & 14 deletions tests/testsuite/alt_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn depend_on_alt_registry() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -62,7 +62,7 @@ fn depend_on_alt_registry_depends_on_same_registry_no_index() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -104,7 +104,7 @@ fn depend_on_alt_registry_depends_on_same_registry() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -146,7 +146,7 @@ fn depend_on_alt_registry_depends_on_crates_io() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -190,7 +190,7 @@ fn registry_and_path_dep_works() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -224,7 +224,7 @@ fn registry_incompatible_with_git() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -255,7 +255,7 @@ fn cannot_publish_to_crates_io_with_registry_dependency() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -312,7 +312,7 @@ fn publish_with_registry_dependency() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -376,7 +376,7 @@ fn alt_registry_and_crates_io_deps() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -479,7 +479,7 @@ fn publish_with_crates_io_dep() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = ["me"]
Expand Down Expand Up @@ -616,7 +616,7 @@ fn bad_registry_name() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -1042,7 +1042,7 @@ fn unknown_registry() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -1215,7 +1215,7 @@ fn registries_index_relative_url() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -1262,7 +1262,7 @@ fn registries_index_relative_path_not_allowed() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down
8 changes: 4 additions & 4 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ fn features_are_unified_among_lib_and_bin_dep_of_same_target() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -332,7 +332,7 @@ fn features_are_not_unified_among_lib_and_bin_dep_of_different_target() {
.file(
"Cargo.toml",
&r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -435,7 +435,7 @@ fn feature_resolution_works_for_cfg_target_specification() {
.file(
"Cargo.toml",
&r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -2181,7 +2181,7 @@ fn build_script_features_for_shared_dependency() {
.file(
"Cargo.toml",
&r#"
[project]
[package]
name = "foo"
version = "0.0.1"
resolver = "2"
Expand Down
10 changes: 5 additions & 5 deletions tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn duplicate_packages_in_cargo_lock() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -263,7 +263,7 @@ fn bad_source_in_cargo_lock() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -654,7 +654,7 @@ warning: unused manifest key: target.foo.bar
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.5.0"
Expand All @@ -667,7 +667,7 @@ warning: unused manifest key: target.foo.bar
p.cargo("build")
.with_stderr(
"\
warning: unused manifest key: project.bulid
warning: unused manifest key: package.bulid
[COMPILING] foo [..]
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
Expand All @@ -679,7 +679,7 @@ warning: unused manifest key: project.bulid
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.5.0"
Expand Down
24 changes: 12 additions & 12 deletions tests/testsuite/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ fn bench_with_lib_dep() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -452,7 +452,7 @@ fn external_bench_explicit() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -550,7 +550,7 @@ fn bench_autodiscover_2015() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -695,7 +695,7 @@ fn lib_bin_same_name() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
authors = []
Expand Down Expand Up @@ -1058,7 +1058,7 @@ fn test_a_bench() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
authors = []
version = "0.1.0"
Expand Down Expand Up @@ -1216,7 +1216,7 @@ fn test_bench_multiple_packages() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
authors = []
version = "0.1.0"
Expand All @@ -1236,7 +1236,7 @@ fn test_bench_multiple_packages() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "bar"
authors = []
version = "0.1.0"
Expand Down Expand Up @@ -1266,7 +1266,7 @@ fn test_bench_multiple_packages() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "baz"
authors = []
version = "0.1.0"
Expand Down Expand Up @@ -1305,7 +1305,7 @@ fn bench_all_workspace() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.1.0"
Expand Down Expand Up @@ -1358,7 +1358,7 @@ fn bench_all_exclude() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.1.0"
Expand Down Expand Up @@ -1403,7 +1403,7 @@ fn bench_all_exclude_glob() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.1.0"
Expand Down Expand Up @@ -1547,7 +1547,7 @@ fn legacy_bench_name() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.1.0"
Expand Down
10 changes: 5 additions & 5 deletions tests/testsuite/binary_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn gated() {
.file(
"Cargo.toml",
r#"
[project]
[package]
name = "foo"
version = "0.0.1"
Expand Down Expand Up @@ -44,7 +44,7 @@ fn binary_name1() {
r#"
cargo-features = ["different-binary-name"]
[project]
[package]
name = "foo"
version = "0.0.1"
Expand Down Expand Up @@ -126,7 +126,7 @@ fn binary_name2() {
r#"
cargo-features = ["different-binary-name"]
[project]
[package]
name = "foo"
version = "0.0.1"
Expand Down Expand Up @@ -212,7 +212,7 @@ fn check_env_vars() {
r#"
cargo-features = ["different-binary-name"]
[project]
[package]
name = "foo"
version = "0.0.1"
Expand Down Expand Up @@ -264,7 +264,7 @@ fn check_msg_format_json() {
r#"
cargo-features = ["different-binary-name"]
[project]
[package]
name = "foo"
version = "0.0.1"
Expand Down
Loading

0 comments on commit 928561a

Please sign in to comment.