Skip to content

Commit

Permalink
Auto merge of #9967 - flip1995:rust_version_meta, r=alexcrichton
Browse files Browse the repository at this point in the history
Add rust_metadata to SerializedPackage

After the rust_version field was stabilized in #9732 this adds the
rust_version as output to the `cargo metadata` command, so tools like
Clippy can read and use it as well.

We will probably need this for rust-lang/rust-clippy#7765
  • Loading branch information
bors committed Oct 12, 2021
2 parents c7957a7 + 390af27 commit 2e6a4e1
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub struct SerializedPackage {
#[serde(skip_serializing_if = "Option::is_none")]
metabuild: Option<Vec<String>>,
default_run: Option<String>,
rust_version: Option<String>,
}

impl Package {
Expand Down Expand Up @@ -268,6 +269,7 @@ impl Package {
metabuild: self.manifest().metabuild().cloned(),
publish: self.publish().as_ref().cloned(),
default_run: self.manifest().default_run().map(|s| s.to_owned()),
rust_version: self.rust_version().map(|s| s.to_owned()),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/doc/man/cargo-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ The output has the following format:
],
/* Optional string that is the default binary picked by cargo run. */
"default_run": null,
/* Optional string that is the minimum supported rust version */
"rust_version": "1.56",
/* Array of keywords from the manifest. */
"keywords": [
"cli"
Expand Down
2 changes: 2 additions & 0 deletions src/doc/man/generated_txt/cargo-metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ OUTPUT FORMAT
],
/* Optional string that is the default binary picked by cargo run. */
"default_run": null,
/* Optional string that is the minimum supported rust version */
"rust_version": "1.56",
/* Array of keywords from the manifest. */
"keywords": [
"cli"
Expand Down
2 changes: 2 additions & 0 deletions src/doc/src/commands/cargo-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ The output has the following format:
],
/* Optional string that is the default binary picked by cargo run. */
"default_run": null,
/* Optional string that is the minimum supported rust version */
"rust_version": "1.56",
/* Array of keywords from the manifest. */
"keywords": [
"cli"
Expand Down
2 changes: 2 additions & 0 deletions src/etc/man/cargo-metadata.1
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ The output has the following format:
],
/* Optional string that is the default binary picked by cargo run. */
"default_run": null,
/* Optional string that is the minimum supported rust version */
"rust_version": "1.56",
/* Array of keywords from the manifest. */
"keywords": [
"cli"
Expand Down
9 changes: 9 additions & 0 deletions tests/testsuite/alt_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ fn alt_reg_metadata() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand Down Expand Up @@ -880,6 +881,7 @@ fn alt_reg_metadata() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand All @@ -905,6 +907,7 @@ fn alt_reg_metadata() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand All @@ -930,6 +933,7 @@ fn alt_reg_metadata() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand Down Expand Up @@ -980,6 +984,7 @@ fn alt_reg_metadata() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand Down Expand Up @@ -1018,6 +1023,7 @@ fn alt_reg_metadata() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand Down Expand Up @@ -1115,6 +1121,7 @@ fn unknown_registry() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand All @@ -1140,6 +1147,7 @@ fn unknown_registry() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand Down Expand Up @@ -1178,6 +1186,7 @@ fn unknown_registry() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/features_namespaced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ fn json_exposed() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"edition": "2015",
"links": null
}
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3147,6 +3147,7 @@ fn metadata_master_consistency() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand Down Expand Up @@ -3185,6 +3186,7 @@ fn metadata_master_consistency() {
"keywords": [],
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"edition": "2015",
Expand Down
Loading

0 comments on commit 2e6a4e1

Please sign in to comment.