Skip to content

Commit e2010e8

Browse files
committed
Modify Context::flag_activated to return ActivateResult
1 parent 4d094c0 commit e2010e8

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/cargo/core/resolver/context.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ use std::collections::HashMap;
22
use std::num::NonZeroU64;
33
use std::rc::Rc;
44

5-
// "ensure" seems to require "bail" be in scope (macro hygiene issue?).
6-
#[allow(unused_imports)]
7-
use failure::{bail, ensure};
5+
use failure::format_err;
86
use log::debug;
97

108
use crate::core::interning::InternedString;
119
use crate::core::{Dependency, PackageId, SourceId, Summary};
12-
use crate::util::CargoResult;
1310
use crate::util::Graph;
1411

1512
use super::dep_cache::RegistryQueryer;
13+
use super::errors::ActivateResult;
1614
use super::types::{ConflictMap, FeaturesSet, ResolveOpts};
1715

1816
pub use super::encode::Metadata;
@@ -109,7 +107,7 @@ impl Context {
109107
summary: &Summary,
110108
opts: &ResolveOpts,
111109
parent: Option<(&Summary, &Dependency)>,
112-
) -> CargoResult<bool> {
110+
) -> ActivateResult<bool> {
113111
let id = summary.package_id();
114112
let age: ContextAge = self.age();
115113
match self.activations.entry(id.as_activations_key()) {
@@ -122,12 +120,15 @@ impl Context {
122120
}
123121
im_rc::hashmap::Entry::Vacant(v) => {
124122
if let Some(link) = summary.links() {
125-
ensure!(
126-
self.links.insert(link, id).is_none(),
127-
"Attempting to resolve a dependency with more then one crate with the \
128-
links={}.\nThis will not build as is. Consider rebuilding the .lock file.",
129-
&*link
130-
);
123+
if self.links.insert(link, id).is_some() {
124+
return Err(format_err!(
125+
"Attempting to resolve a dependency with more then \
126+
one crate with links={}.\nThis will not build as \
127+
is. Consider rebuilding the .lock file.",
128+
&*link
129+
)
130+
.into());
131+
}
131132
}
132133
v.insert((summary.clone(), age));
133134

0 commit comments

Comments
 (0)