Remove uses of Option<MarkerTree> (#5978)

## Summary

Follow up to https://github.com/astral-sh/uv/pull/5898. This should fix
some of the failures in https://github.com/astral-sh/uv/pull/5887 where
`uv lock --locked` is failing due to `Some(true)` and `None` markers not
comparing equal.
This commit is contained in:
Ibraheem Ahmed 2024-08-10 13:23:29 -04:00 committed by GitHub
parent 4eced1bd0c
commit f5110f7b5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 228 additions and 330 deletions

View file

@ -60,11 +60,7 @@ impl Constraints {
// ASSUMPTION: There is one `extra = "..."`, and it's either the only marker or part
// of the main conjunction.
let Some(extra_expression) = requirement
.marker
.as_ref()
.and_then(MarkerTree::top_level_extra)
else {
let Some(extra_expression) = requirement.marker.top_level_extra() else {
// Case 2: A non-optional dependency with constraint(s).
return Either::Right(Either::Right(
std::iter::once(requirement).chain(constraints.iter().map(Cow::Borrowed)),
@ -79,11 +75,9 @@ impl Constraints {
constraints.iter().cloned().map(move |constraint| {
// Add the extra to the override marker.
let mut joint_marker = MarkerTree::expression(extra_expression.clone());
if let Some(marker) = &constraint.marker {
joint_marker.and(marker.clone());
}
joint_marker.and(constraint.marker.clone());
Cow::Owned(Requirement {
marker: Some(joint_marker.clone()),
marker: joint_marker,
..constraint
})
}),