Skip to content

Commit

Permalink
Auto merge of #5292 - djc:feature-requirements, r=alexcrichton
Browse files Browse the repository at this point in the history
Revert serialization of features to string type

Accidentally broken during #5270 and only noticed after merge.

cc @matklad @Eh2406
  • Loading branch information
bors committed Apr 4, 2018
2 parents 75f77fc + 540bd45 commit 0729e06
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 20 additions & 1 deletion src/cargo/core/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use std::mem;
use std::rc::Rc;

use semver::Version;

use serde::{Serialize, Serializer};

use core::{Dependency, PackageId, SourceId};
use core::interning::InternedString;

Expand Down Expand Up @@ -190,7 +193,7 @@ fn build_feature_map(
/// * A feature in a depedency
///
/// The selection between these 3 things happens as part of the construction of the FeatureValue.
#[derive(Clone, Debug, Serialize)]
#[derive(Clone, Debug)]
pub enum FeatureValue {
Feature(InternedString),
Crate(InternedString),
Expand Down Expand Up @@ -227,4 +230,20 @@ impl FeatureValue {
}
}

impl Serialize for FeatureValue {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
use self::FeatureValue::*;
match *self {
Feature(ref f) => serializer.serialize_str(f),
Crate(ref c) => serializer.serialize_str(c),
CrateFeature(ref c, ref f) => {
serializer.serialize_str(&[c.as_ref(), f.as_ref()].join("/"))
}
}
}
}

pub type FeatureMap = BTreeMap<String, Vec<FeatureValue>>;
4 changes: 1 addition & 3 deletions tests/testsuite/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ optional_feat = []
],
"features": {
"default": [
{
"Feature": "default_feat"
}
"default_feat"
],
"default_feat": [],
"optional_feat": []
Expand Down

0 comments on commit 0729e06

Please sign in to comment.