|
1 | 1 | use super::dep_cache::RegistryQueryer;
|
2 | 2 | use super::errors::ActivateResult;
|
3 |
| -use super::types::{ConflictMap, ConflictReason, FeaturesSet, ResolveOpts}; |
| 3 | +use super::types::{ActivationsKey, ConflictMap, ConflictReason, FeaturesSet, ResolveOpts}; |
4 | 4 | use super::RequestedFeatures;
|
5 |
| -use crate::core::{Dependency, PackageId, SourceId, Summary}; |
| 5 | +use crate::core::{Dependency, PackageId, Summary}; |
6 | 6 | use crate::util::interning::InternedString;
|
7 | 7 | use crate::util::Graph;
|
8 | 8 | use anyhow::format_err;
|
9 | 9 | use std::collections::HashMap;
|
10 |
| -use std::num::NonZeroU64; |
11 | 10 | use tracing::debug;
|
12 | 11 |
|
13 | 12 | // A `Context` is basically a bunch of local resolution information which is
|
@@ -39,39 +38,9 @@ pub type ContextAge = usize;
|
39 | 38 | /// By storing this in a hash map we ensure that there is only one
|
40 | 39 | /// semver compatible version of each crate.
|
41 | 40 | /// This all so stores the `ContextAge`.
|
42 |
| -pub type ActivationsKey = (InternedString, SourceId, SemverCompatibility); |
43 |
| - |
44 | 41 | pub type Activations =
|
45 | 42 | im_rc::HashMap<ActivationsKey, (Summary, ContextAge), rustc_hash::FxBuildHasher>;
|
46 | 43 |
|
47 |
| -/// A type that represents when cargo treats two Versions as compatible. |
48 |
| -/// Versions `a` and `b` are compatible if their left-most nonzero digit is the |
49 |
| -/// same. |
50 |
| -#[derive(Clone, Copy, Eq, PartialEq, Hash, Debug, PartialOrd, Ord)] |
51 |
| -pub enum SemverCompatibility { |
52 |
| - Major(NonZeroU64), |
53 |
| - Minor(NonZeroU64), |
54 |
| - Patch(u64), |
55 |
| -} |
56 |
| - |
57 |
| -impl From<&semver::Version> for SemverCompatibility { |
58 |
| - fn from(ver: &semver::Version) -> Self { |
59 |
| - if let Some(m) = NonZeroU64::new(ver.major) { |
60 |
| - return SemverCompatibility::Major(m); |
61 |
| - } |
62 |
| - if let Some(m) = NonZeroU64::new(ver.minor) { |
63 |
| - return SemverCompatibility::Minor(m); |
64 |
| - } |
65 |
| - SemverCompatibility::Patch(ver.patch) |
66 |
| - } |
67 |
| -} |
68 |
| - |
69 |
| -impl PackageId { |
70 |
| - pub fn as_activations_key(self) -> ActivationsKey { |
71 |
| - (self.name(), self.source_id(), self.version().into()) |
72 |
| - } |
73 |
| -} |
74 |
| - |
75 | 44 | impl ResolverContext {
|
76 | 45 | pub fn new() -> ResolverContext {
|
77 | 46 | ResolverContext {
|
@@ -137,7 +106,8 @@ impl ResolverContext {
|
137 | 106 | // versions came from a `[patch]` source.
|
138 | 107 | if let Some((_, dep)) = parent {
|
139 | 108 | if dep.source_id() != id.source_id() {
|
140 |
| - let key = (id.name(), dep.source_id(), id.version().into()); |
| 109 | + let key = |
| 110 | + ActivationsKey::new(id.name(), id.version().into(), dep.source_id()); |
141 | 111 | let prev = self.activations.insert(key, (summary.clone(), age));
|
142 | 112 | if let Some((previous_summary, _)) = prev {
|
143 | 113 | return Err(
|
|
0 commit comments