Skip to content

Commit 0729e06

Browse files
committed
Auto merge of #5292 - djc:feature-requirements, r=alexcrichton
Revert serialization of features to string type Accidentally broken during #5270 and only noticed after merge. cc @matklad @Eh2406
2 parents 75f77fc + 540bd45 commit 0729e06

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/cargo/core/summary.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ use std::mem;
33
use std::rc::Rc;
44

55
use semver::Version;
6+
7+
use serde::{Serialize, Serializer};
8+
69
use core::{Dependency, PackageId, SourceId};
710
use core::interning::InternedString;
811

@@ -190,7 +193,7 @@ fn build_feature_map(
190193
/// * A feature in a depedency
191194
///
192195
/// The selection between these 3 things happens as part of the construction of the FeatureValue.
193-
#[derive(Clone, Debug, Serialize)]
196+
#[derive(Clone, Debug)]
194197
pub enum FeatureValue {
195198
Feature(InternedString),
196199
Crate(InternedString),
@@ -227,4 +230,20 @@ impl FeatureValue {
227230
}
228231
}
229232

233+
impl Serialize for FeatureValue {
234+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
235+
where
236+
S: Serializer,
237+
{
238+
use self::FeatureValue::*;
239+
match *self {
240+
Feature(ref f) => serializer.serialize_str(f),
241+
Crate(ref c) => serializer.serialize_str(c),
242+
CrateFeature(ref c, ref f) => {
243+
serializer.serialize_str(&[c.as_ref(), f.as_ref()].join("/"))
244+
}
245+
}
246+
}
247+
}
248+
230249
pub type FeatureMap = BTreeMap<String, Vec<FeatureValue>>;

tests/testsuite/metadata.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ optional_feat = []
192192
],
193193
"features": {
194194
"default": [
195-
{
196-
"Feature": "default_feat"
197-
}
195+
"default_feat"
198196
],
199197
"default_feat": [],
200198
"optional_feat": []

0 commit comments

Comments
 (0)