Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo: unused manifest key; use package metadata? #273

Closed
wchargin opened this issue Oct 31, 2020 · 0 comments · Fixed by #274
Closed

cargo: unused manifest key; use package metadata? #273

wchargin opened this issue Oct 31, 2020 · 0 comments · Fixed by #274

Comments

@wchargin
Copy link
Contributor

When I extend my Cargo.toml with

[raze]
workspace_path = "//third_party/rust"
genmode = "Remote"

per the documentation, cargo raze works great! But all cargo
commands also now print a warning about the raze key:

$ cargo check
warning: unused manifest key: raze
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s

The Cargo docs mention that “tools which would like to store package
configuration in Cargo.toml” can use the package.metadata table to
ignore that warning.
I think that this would just amount to changing
the table from [raze] to [package.metadata.raze]:

[package.metadata.raze]
workspace_path = "//third_party/rust"
genmode = "Remote"

When I do so, Cargo indeed no longer complains, but now cargo-raze
can’t find my configuration:

$ cargo raze
Error: Raze failed with cause: "missing field `raze` at line 20 column 1"

Perhaps cargo-raze could be modified to accept package.metadata.raze
as well as raze, and then maybe to drop support for bare raze at
such a time when that breaking change would be considered acceptable?

wchargin added a commit to wchargin/cargo-raze that referenced this issue Oct 31, 2020
Cargo sets aside the [`[package.metadata]`][md] namespace for use by
third-party tools like `cargo-raze`. By specifying configuration under
`[package.metadata.raze]` rather than `[raze]`, we avoid an “unused
manifest key: raze” warning on every Cargo command.

This patch teaches `cargo-raze` to accept either `[raze]` or the new
`[package.metadata.raze]`. In case of conflict, it prints a warning and
uses the value of `[package.metadata.raze]`. In the future, we can
remove the `[raze]` key entirely if desired.

Fixes google#273.

Changes outside of `impl/` generated by:

```
git ls-files -z ':!impl' | xargs -0 sed -i 's/\[raze/[package.metadata.raze/'
```

[md]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-metadata-table

Test Plan:
With this patch, running `./smoke-test.sh` passes both before and after
updating all the examples with the above `sed` command. Before the `sed`
update, the smoke test prints the deprecation warning, as desired.

wchargin-branch: toml-package-metadata-raze
wchargin-source: 4932fedcc808b17506aadf4b69f6aa78850fe5c6
acmcarther pushed a commit that referenced this issue Nov 4, 2020
* Accept `[package.metadata.raze]`, superseding `[raze]`

Cargo sets aside the [`[package.metadata]`][md] namespace for use by
third-party tools like `cargo-raze`. By specifying configuration under
`[package.metadata.raze]` rather than `[raze]`, we avoid an “unused
manifest key: raze” warning on every Cargo command.

This patch teaches `cargo-raze` to accept either `[raze]` or the new
`[package.metadata.raze]`. In case of conflict, it prints a warning and
uses the value of `[package.metadata.raze]`. In the future, we can
remove the `[raze]` key entirely if desired.

Fixes #273.

Changes outside of `impl/` generated by:

```
git ls-files -z ':!impl' | xargs -0 sed -i 's/\[raze/[package.metadata.raze/'
```

[md]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-metadata-table

Test Plan:
With this patch, running `./smoke-test.sh` passes both before and after
updating all the examples with the above `sed` command. Before the `sed`
update, the smoke test prints the deprecation warning, as desired.

wchargin-branch: toml-package-metadata-raze
wchargin-source: 4932fedcc808b17506aadf4b69f6aa78850fe5c6

* [update patch]

wchargin-branch: toml-package-metadata-raze
wchargin-source: f2b7fb6fb07bd1f478aa1e8c14f7d623f86f69b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant