@@ -2,12 +2,11 @@ use super::dep_cache::RegistryQueryer;
2
2
use super :: errors:: ActivateResult ;
3
3
use super :: types:: { ConflictMap , ConflictReason , FeaturesSet , ResolveOpts } ;
4
4
use super :: RequestedFeatures ;
5
- use crate :: core:: { Dependency , PackageId , SourceId , Summary } ;
5
+ use crate :: core:: { ActivationsKey , 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
@@ -22,56 +21,21 @@ pub struct ResolverContext {
22
21
pub resolve_features : im_rc:: HashMap < PackageId , FeaturesSet , rustc_hash:: FxBuildHasher > ,
23
22
/// get the package that will be linking to a native library by its links attribute
24
23
pub links : im_rc:: HashMap < InternedString , PackageId , rustc_hash:: FxBuildHasher > ,
25
-
26
24
/// a way to look up for a package in activations what packages required it
27
25
/// and all of the exact deps that it fulfilled.
28
26
pub parents : Graph < PackageId , im_rc:: HashSet < Dependency , rustc_hash:: FxBuildHasher > > ,
29
27
}
30
28
29
+ pub type Activations =
30
+ im_rc:: HashMap < ActivationsKey , ( Summary , ContextAge ) , rustc_hash:: FxBuildHasher > ;
31
+
31
32
/// When backtracking it can be useful to know how far back to go.
32
33
/// The `ContextAge` of a `Context` is a monotonically increasing counter of the number
33
34
/// of decisions made to get to this state.
34
35
/// Several structures store the `ContextAge` when it was added,
35
36
/// to be used in `find_candidate` for backtracking.
36
37
pub type ContextAge = usize ;
37
38
38
- /// Find the activated version of a crate based on the name, source, and semver compatibility.
39
- /// By storing this in a hash map we ensure that there is only one
40
- /// semver compatible version of each crate.
41
- /// This all so stores the `ContextAge`.
42
- pub type ActivationsKey = ( InternedString , SourceId , SemverCompatibility ) ;
43
-
44
- pub type Activations =
45
- im_rc:: HashMap < ActivationsKey , ( Summary , ContextAge ) , rustc_hash:: FxBuildHasher > ;
46
-
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
39
impl ResolverContext {
76
40
pub fn new ( ) -> ResolverContext {
77
41
ResolverContext {
0 commit comments