Skip to content

Commit

Permalink
implement conditions in from_provider_async function
Browse files Browse the repository at this point in the history
  • Loading branch information
prsabahrami committed Jan 24, 2025
1 parent 2155d6b commit eaeaf42
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,13 @@ impl DependencySnapshot {
}

for &req in deps.requirements.iter() {
let (_, requirement) = req.into_condition_and_requirement(); // TODO: condition
let (condition, requirement) = req.into_condition_and_requirement();

if let Some(condition) = condition {
if seen.insert(Element::VersionSet(condition)) {
queue.push_back(Element::VersionSet(condition));
}
}

match requirement {
Requirement::Single(version_set) => {
Expand Down
4 changes: 2 additions & 2 deletions src/solver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1926,12 +1926,12 @@ async fn add_clauses_for_solvables<D: DependencyProvider>(
);
}


if let Some((condition, condition_candidates)) = condition {
tracing::trace!(
"Adding conditional clauses for {} with condition {}",
requirement.display(cache.provider()),
std::convert::Into::<Requirement>::into(condition).display(cache.provider()),
std::convert::Into::<Requirement>::into(condition)
.display(cache.provider()),
);

let condition_version_set_variables = requirement_to_sorted_candidates.insert(
Expand Down
10 changes: 4 additions & 6 deletions tests/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,10 @@ impl DependencyProvider for BundleBoxProvider {
.into()
};

result
.requirements
.push(ConditionalRequirement {
requirement,
condition: None,
});
result.requirements.push(ConditionalRequirement {
requirement,
condition: None,
});
}

for req in &deps.constrains {
Expand Down

0 comments on commit eaeaf42

Please sign in to comment.