Skip to content

Commit

Permalink
Auto merge of #5834 - Undin:metadata-edition, r=alexcrichton
Browse files Browse the repository at this point in the history
Add edition info into metadata

Since edition feature was introduced, external tools have to support this new feature.
But cargo metadata doesn't provide info about package edition.
This commit adds edition field to `SerializedPackage` struct to add the corresponding field into metadata output.
  • Loading branch information
bors committed Aug 1, 2018
2 parents d06fe7b + 3fdce22 commit f14aea5
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ struct SerializedTarget<'a> {
crate_types: Vec<&'a str>,
name: &'a str,
src_path: &'a PathBuf,
edition: &'a str,
}

impl ser::Serialize for Target {
Expand All @@ -237,6 +238,7 @@ impl ser::Serialize for Target {
crate_types: self.rustc_crate_types(),
name: &self.name,
src_path: &self.src_path.path,
edition: &self.edition.to_string()
}.serialize(s)
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct SerializedPackage<'a> {
keywords: &'a [String],
readme: Option<&'a str>,
repository: Option<&'a str>,
edition: &'a str,
}

impl ser::Serialize for Package {
Expand Down Expand Up @@ -84,6 +85,7 @@ impl ser::Serialize for Package {
keywords,
readme,
repository,
edition: &self.manifest.edition().to_string(),
}.serialize(s)
}
}
Expand Down
10 changes: 10 additions & 0 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3399,6 +3399,7 @@ fn compiler_json_error_format() {
"target":{
"kind":["custom-build"],
"crate_types":["bin"],
"edition": "2015",
"name":"build-script-build",
"src_path":"[..]build.rs"
},
Expand All @@ -3420,6 +3421,7 @@ fn compiler_json_error_format() {
"target":{
"kind":["lib"],
"crate_types":["lib"],
"edition": "2015",
"name":"bar",
"src_path":"[..]lib.rs"
},
Expand All @@ -3440,6 +3442,7 @@ fn compiler_json_error_format() {
"target":{
"kind":["lib"],
"crate_types":["lib"],
"edition": "2015",
"name":"bar",
"src_path":"[..]lib.rs"
},
Expand All @@ -3462,6 +3465,7 @@ fn compiler_json_error_format() {
"target":{
"kind":["bin"],
"crate_types":["bin"],
"edition": "2015",
"name":"foo",
"src_path":"[..]main.rs"
},
Expand All @@ -3474,6 +3478,7 @@ fn compiler_json_error_format() {
"target":{
"kind":["bin"],
"crate_types":["bin"],
"edition": "2015",
"name":"foo",
"src_path":"[..]main.rs"
},
Expand Down Expand Up @@ -3504,6 +3509,7 @@ fn compiler_json_error_format() {
"target":{
"kind":["custom-build"],
"crate_types":["bin"],
"edition": "2015",
"name":"build-script-build",
"src_path":"[..]build.rs"
},
Expand Down Expand Up @@ -3533,6 +3539,7 @@ fn compiler_json_error_format() {
"target":{
"kind":["lib"],
"crate_types":["lib"],
"edition": "2015",
"name":"bar",
"src_path":"[..]lib.rs"
},
Expand All @@ -3555,6 +3562,7 @@ fn compiler_json_error_format() {
"target":{
"kind":["bin"],
"crate_types":["bin"],
"edition": "2015",
"name":"foo",
"src_path":"[..]main.rs"
},
Expand Down Expand Up @@ -3614,6 +3622,7 @@ fn message_format_json_forward_stderr() {
"target":{
"kind":["bin"],
"crate_types":["bin"],
"edition": "2015",
"name":"foo",
"src_path":"[..]"
},
Expand All @@ -3626,6 +3635,7 @@ fn message_format_json_forward_stderr() {
"target":{
"kind":["bin"],
"crate_types":["bin"],
"edition": "2015",
"name":"foo",
"src_path":"[..]"
},
Expand Down
Loading

0 comments on commit f14aea5

Please sign in to comment.