Move resolver Context initialization into a method
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Thu, 29 Mar 2018 09:07:49 +0000 (11:07 +0200)
committerDirkjan Ochtman <dirkjan@ochtman.nl>
Thu, 29 Mar 2018 20:05:12 +0000 (22:05 +0200)
src/cargo/core/resolver/context.rs
src/cargo/core/resolver/mod.rs

index 215a8a98cc5c574f72b6547028fb4a5e4a1eb77e..eaf7036d97f2ce0d813bd8d8771bfc147e22b57c 100644 (file)
@@ -37,6 +37,17 @@ pub struct Context {
 }
 
 impl Context {
+    pub fn new() -> Context {
+        Context {
+            resolve_graph: RcList::new(),
+            resolve_features: HashMap::new(),
+            links: HashMap::new(),
+            resolve_replacements: RcList::new(),
+            activations: HashMap::new(),
+            warnings: RcList::new(),
+        }
+    }
+
     /// Activate this summary by inserting it into our list of known activations.
     ///
     /// Returns true if this summary with the given method is already activated.
index e72439b146c6e1f68cfe37526eb619cd3b46807a..3b71af2a7c6a6e94ef1a3212756f061354f5c63f 100644 (file)
@@ -63,7 +63,7 @@ use util::profile;
 
 use self::context::{Activations, Context};
 use self::types::{ActivateError, ActivateResult, Candidate, ConflictReason, DepsFrame, GraphNode};
-use self::types::{RcList, RcVecIter, RegistryQueryer};
+use self::types::{RcVecIter, RegistryQueryer};
 
 pub use self::encode::{EncodableDependency, EncodablePackageId, EncodableResolve};
 pub use self::encode::{Metadata, WorkspaceResolve};
@@ -113,14 +113,7 @@ pub fn resolve(
     config: Option<&Config>,
     print_warnings: bool,
 ) -> CargoResult<Resolve> {
-    let cx = Context {
-        resolve_graph: RcList::new(),
-        resolve_features: HashMap::new(),
-        links: HashMap::new(),
-        resolve_replacements: RcList::new(),
-        activations: HashMap::new(),
-        warnings: RcList::new(),
-    };
+    let cx = Context::new();
     let _p = profile::start("resolving");
     let minimal_versions = match config {
         Some(config) => config.cli_unstable().minimal_versions,