-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Migrate from rustc-serialize to Serde #3682
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
src/cargo/util/machine_message.rs
Outdated
println!("{}", Json::Object(map)); | ||
let mut json: Value = serde_json::to_value(&t).unwrap(); | ||
json.as_object_mut().unwrap() | ||
.insert("reason".to_string(), Value::String(t.reason().to_string())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I released index_mut
in serde_json 0.9.6:
json["reason"] = json!(t.reason());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah unfortunately that requires an IndexSet
trait I think as otherwise this attempts to look up a slot in the json which doesn't exist yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it works 😺
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh the compile error I encountered was because I forgot to update serde_json.
Ahhh clever! I was flabbergasted this worked but when I checked up on the implementation it was a nice trick!
I approve 👍
src/cargo/util/toml.rs
Outdated
type Value = TomlVersion; | ||
|
||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
formatter.write_str("an semver version") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"a semver version"
f389d25
to
4ee6523
Compare
☔ The latest upstream changes (presumably #3668) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #3733) made this pull request unmergeable. Please resolve the merge conflicts. |
This commit migrates Cargo as much as possible from rustc-serialize to Serde. This not only provides an excellent testing ground for the toml 0.3 release but it also is a big boost to the speed of parsing the JSON bits of the registry. This doesn't completely excise the dependency just yet as docopt still requires it along with handlebars. I'm sure though that in time those crates will migrate to serde!
@bors r+ |
📌 Commit a5a298f has been approved by |
Migrate from rustc-serialize to Serde This commit migrates Cargo as much as possible from rustc-serialize to Serde. This not only provides an excellent testing ground for the toml 0.3 release but it also is a big boost to the speed of parsing the JSON bits of the registry. This doesn't completely excise the dependency just yet as docopt still requires it along with handlebars. I'm sure though that in time those crates will migrate to serde!
☀️ Test successful - status-appveyor, status-travis |
@alexcrichton seems I'm a little late for this. You can use feature flag |
Use serde type system for handlebars This will help cargo to drop rustc_serialize as dependency (#3682). Handlebars actually supports using serde_json as its type system instead of rustc_serialize. And I'm planning to drop rustc_serialize in future releases.
@sunng87 was gonna mention here as well that it's definitely welcome, thanks for the PR! |
This commit migrates Cargo as much as possible from rustc-serialize to
Serde. This not only provides an excellent testing ground for the toml
0.3 release but it also is a big boost to the speed of parsing the JSON
bits of the registry.
This doesn't completely excise the dependency just yet as docopt still
requires it along with handlebars. I'm sure though that in time those
crates will migrate to serde!