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

Don't warn about metadata keys in the manifest #2668

Merged
merged 1 commit into from
Jun 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cargo/util/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ pub fn to_manifest(contents: &[u8],
return Ok((manifest, paths));

fn add_unused_keys(m: &mut Manifest, toml: &toml::Value, key: String) {
if key == "package.metadata" {
return
}
match *toml {
toml::Value::Table(ref table) => {
for (k, v) in table.iter() {
Expand Down
19 changes: 19 additions & 0 deletions src/doc/manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@ provide useful information to users of the registry and also influence the
search ranking of a crate. It is highly discouraged to omit everything in a
published crate.

## The `metadata` Table (optional)

Cargo by default will warn about unused keys in `Cargo.toml` to assist in
detecting typos and such. The `package.metadata` table, however, is completely
ignored by Cargo and will not be warned about. This section can be used for
tools which would like to store project configuration in `Cargo.toml`. For
example:

```toml
[package]
name = "..."
# ...

# Metadata used when generating an Android APK, for example.
[package.metadata.android]
package-name = "my-awesome-android-app"
assets = "path/to/static"
```

# Dependency Sections

See the [specifying dependencies page](specifying-dependencies.html) for
Expand Down
23 changes: 23 additions & 0 deletions tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2240,3 +2240,26 @@ fn explicit_color_config_is_propagated_to_rustc() {
-L dependency=[..]target[..]debug[..]deps`
"));
}

#[test]
fn no_warn_about_package_metadata() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.1"
authors = []

[package.metadata]
foo = "bar"
a = true
b = 3

[package.metadata.another]
bar = 3
"#)
.file("src/lib.rs", "");
assert_that(p.cargo_process("build"),
execs().with_status(0)
.with_stderr("[..] foo v0.0.1 ([..])\n"));
}