Skip to content

Commit 390af27

Browse files
committed
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.
1 parent dea587a commit 390af27

File tree

11 files changed

+74
-0
lines changed

11 files changed

+74
-0
lines changed

src/cargo/core/package.rs

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub struct SerializedPackage {
102102
#[serde(skip_serializing_if = "Option::is_none")]
103103
metabuild: Option<Vec<String>>,
104104
default_run: Option<String>,
105+
rust_version: Option<String>,
105106
}
106107

107108
impl Package {
@@ -268,6 +269,7 @@ impl Package {
268269
metabuild: self.manifest().metabuild().cloned(),
269270
publish: self.publish().as_ref().cloned(),
270271
default_run: self.manifest().default_run().map(|s| s.to_owned()),
272+
rust_version: self.rust_version().map(|s| s.to_owned()),
271273
}
272274
}
273275
}

src/doc/man/cargo-metadata.md

+2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ The output has the following format:
182182
],
183183
/* Optional string that is the default binary picked by cargo run. */
184184
"default_run": null,
185+
/* Optional string that is the minimum supported rust version */
186+
"rust_version": "1.56",
185187
/* Array of keywords from the manifest. */
186188
"keywords": [
187189
"cli"

src/doc/man/generated_txt/cargo-metadata.txt

+2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ OUTPUT FORMAT
177177
],
178178
/* Optional string that is the default binary picked by cargo run. */
179179
"default_run": null,
180+
/* Optional string that is the minimum supported rust version */
181+
"rust_version": "1.56",
180182
/* Array of keywords from the manifest. */
181183
"keywords": [
182184
"cli"

src/doc/src/commands/cargo-metadata.md

+2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ The output has the following format:
182182
],
183183
/* Optional string that is the default binary picked by cargo run. */
184184
"default_run": null,
185+
/* Optional string that is the minimum supported rust version */
186+
"rust_version": "1.56",
185187
/* Array of keywords from the manifest. */
186188
"keywords": [
187189
"cli"

src/etc/man/cargo-metadata.1

+2
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ The output has the following format:
179179
],
180180
/* Optional string that is the default binary picked by cargo run. */
181181
"default_run": null,
182+
/* Optional string that is the minimum supported rust version */
183+
"rust_version": "1.56",
182184
/* Array of keywords from the manifest. */
183185
"keywords": [
184186
"cli"

tests/testsuite/alt_registry.rs

+9
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ fn alt_reg_metadata() {
823823
"keywords": [],
824824
"readme": null,
825825
"repository": null,
826+
"rust_version": null,
826827
"homepage": null,
827828
"documentation": null,
828829
"edition": "2015",
@@ -880,6 +881,7 @@ fn alt_reg_metadata() {
880881
"keywords": [],
881882
"readme": null,
882883
"repository": null,
884+
"rust_version": null,
883885
"homepage": null,
884886
"documentation": null,
885887
"edition": "2015",
@@ -905,6 +907,7 @@ fn alt_reg_metadata() {
905907
"keywords": [],
906908
"readme": null,
907909
"repository": null,
910+
"rust_version": null,
908911
"homepage": null,
909912
"documentation": null,
910913
"edition": "2015",
@@ -930,6 +933,7 @@ fn alt_reg_metadata() {
930933
"keywords": [],
931934
"readme": null,
932935
"repository": null,
936+
"rust_version": null,
933937
"homepage": null,
934938
"documentation": null,
935939
"edition": "2015",
@@ -980,6 +984,7 @@ fn alt_reg_metadata() {
980984
"keywords": [],
981985
"readme": null,
982986
"repository": null,
987+
"rust_version": null,
983988
"homepage": null,
984989
"documentation": null,
985990
"edition": "2015",
@@ -1018,6 +1023,7 @@ fn alt_reg_metadata() {
10181023
"keywords": [],
10191024
"readme": null,
10201025
"repository": null,
1026+
"rust_version": null,
10211027
"homepage": null,
10221028
"documentation": null,
10231029
"edition": "2015",
@@ -1115,6 +1121,7 @@ fn unknown_registry() {
11151121
"keywords": [],
11161122
"readme": null,
11171123
"repository": null,
1124+
"rust_version": null,
11181125
"homepage": null,
11191126
"documentation": null,
11201127
"edition": "2015",
@@ -1140,6 +1147,7 @@ fn unknown_registry() {
11401147
"keywords": [],
11411148
"readme": null,
11421149
"repository": null,
1150+
"rust_version": null,
11431151
"homepage": null,
11441152
"documentation": null,
11451153
"edition": "2015",
@@ -1178,6 +1186,7 @@ fn unknown_registry() {
11781186
"keywords": [],
11791187
"readme": null,
11801188
"repository": null,
1189+
"rust_version": null,
11811190
"homepage": null,
11821191
"documentation": null,
11831192
"edition": "2015",

tests/testsuite/features_namespaced.rs

+1
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ fn json_exposed() {
715715
"keywords": [],
716716
"readme": null,
717717
"repository": null,
718+
"rust_version": null,
718719
"edition": "2015",
719720
"links": null
720721
}

tests/testsuite/git.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3147,6 +3147,7 @@ fn metadata_master_consistency() {
31473147
"keywords": [],
31483148
"readme": null,
31493149
"repository": null,
3150+
"rust_version": null,
31503151
"homepage": null,
31513152
"documentation": null,
31523153
"edition": "2015",
@@ -3185,6 +3186,7 @@ fn metadata_master_consistency() {
31853186
"keywords": [],
31863187
"readme": null,
31873188
"repository": null,
3189+
"rust_version": null,
31883190
"homepage": null,
31893191
"documentation": null,
31903192
"edition": "2015",

0 commit comments

Comments
 (0)