Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 7 additions & 26 deletions top-crates/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::collections::btree_map::Entry;
use std::fs::File;
use std::io::{Read, Write};

use cargo::core::{Dependency, Package, Source, SourceId, Summary};
use cargo::core::{Dependency, Package, Source, SourceId};
use cargo::core::registry::PackageRegistry;
use cargo::core::resolver::{self, Method, Resolve};
use cargo::sources::RegistrySource;
Expand Down Expand Up @@ -158,29 +158,6 @@ impl TopCrates {
}
}

fn decide_features(summary: &Summary) -> Method<'static> {
// Enable `playground` feature if present.
if summary.features().contains_key("playground") {
// Would put this in a lazy_static, but its type is Vec<InternedString>
// and InternedString is not publicly nameable.
let features = Method::split_features(&["playground".to_owned()]);

Method::Required {
dev_deps: false,
features: Box::leak(Box::new(features)),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whew, that was in there for too long!

uses_default_features: false,
all_features: false,
}
} else {
Method::Required {
dev_deps: false,
features: &[],
uses_default_features: true,
all_features: false,
}
}
}

fn unique_latest_crates(resolve: Resolve) -> BTreeMap<String, DependencySpec> {
let mut uniqs = BTreeMap::new();
for pkg in resolve.iter() {
Expand Down Expand Up @@ -328,8 +305,12 @@ fn main() {
.unwrap_or_else(|| panic!("Registry has no viable versions of {}", name));

// Add a dependency on this crate.
let method = decide_features(&summary);
summaries.push((summary, method));
summaries.push((summary, Method::Required {
dev_deps: false,
features: &[],
uses_default_features: true,
all_features: false,
}));
}

// Resolve transitive dependencies.
Expand Down