From 7fece9b90a07ab8479ba9445f90cedc3b08f61a8 Mon Sep 17 00:00:00 2001 From: konsti Date: Wed, 16 Jul 2025 15:21:22 +0100 Subject: [PATCH] Remove marker from `Edge` (#14649) It seems that this field is unused. --- crates/uv-distribution-types/src/dist_error.rs | 4 ++-- crates/uv-distribution-types/src/resolution.rs | 9 ++++----- crates/uv-resolver/src/lock/export/pylock_toml.rs | 2 +- crates/uv-resolver/src/lock/installable.rs | 13 ++++++------- crates/uv-resolver/src/resolution/output.rs | 13 ++++--------- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/crates/uv-distribution-types/src/dist_error.rs b/crates/uv-distribution-types/src/dist_error.rs index a452ce663..d2cfee16d 100644 --- a/crates/uv-distribution-types/src/dist_error.rs +++ b/crates/uv-distribution-types/src/dist_error.rs @@ -131,11 +131,11 @@ impl DerivationChain { )); let target = edge.source(); let extra = match edge.weight() { - Edge::Optional(extra, ..) => Some(extra.clone()), + Edge::Optional(extra) => Some(extra.clone()), _ => None, }; let group = match edge.weight() { - Edge::Dev(group, ..) => Some(group.clone()), + Edge::Dev(group) => Some(group.clone()), _ => None, }; queue.push_back((target, extra, group, path)); diff --git a/crates/uv-distribution-types/src/resolution.rs b/crates/uv-distribution-types/src/resolution.rs index 5ff34adf5..e690b8693 100644 --- a/crates/uv-distribution-types/src/resolution.rs +++ b/crates/uv-distribution-types/src/resolution.rs @@ -1,6 +1,5 @@ use uv_distribution_filename::DistExtension; use uv_normalize::{ExtraName, GroupName, PackageName}; -use uv_pep508::MarkerTree; use uv_pypi_types::{HashDigest, HashDigests}; use crate::{ @@ -202,12 +201,12 @@ impl Node { } } -/// An edge in the resolution graph, along with the marker that must be satisfied to traverse it. +/// An edge in the resolution graph. #[derive(Debug, Clone)] pub enum Edge { - Prod(MarkerTree), - Optional(ExtraName, MarkerTree), - Dev(GroupName, MarkerTree), + Prod, + Optional(ExtraName), + Dev(GroupName), } impl From<&ResolvedDist> for RequirementSource { diff --git a/crates/uv-resolver/src/lock/export/pylock_toml.rs b/crates/uv-resolver/src/lock/export/pylock_toml.rs index d2c2383a5..8a53fd8f7 100644 --- a/crates/uv-resolver/src/lock/export/pylock_toml.rs +++ b/crates/uv-resolver/src/lock/export/pylock_toml.rs @@ -1152,7 +1152,7 @@ impl<'lock> PylockToml { }; let index = graph.add_node(dist); - graph.add_edge(root, index, Edge::Prod(package.marker)); + graph.add_edge(root, index, Edge::Prod); } Ok(Resolution::new(graph)) diff --git a/crates/uv-resolver/src/lock/installable.rs b/crates/uv-resolver/src/lock/installable.rs index e3cdbf019..4851306da 100644 --- a/crates/uv-resolver/src/lock/installable.rs +++ b/crates/uv-resolver/src/lock/installable.rs @@ -13,7 +13,6 @@ use uv_configuration::ExtrasSpecificationWithDefaults; use uv_configuration::{BuildOptions, DependencyGroupsWithDefaults, InstallOptions}; use uv_distribution_types::{Edge, Node, Resolution, ResolvedDist}; use uv_normalize::{ExtraName, GroupName, PackageName}; -use uv_pep508::MarkerTree; use uv_platform_tags::Tags; use uv_pypi_types::ResolverMarkerEnvironment; @@ -113,7 +112,7 @@ pub trait Installable<'lock> { inverse.insert(&dist.id, index); // Add an edge from the root. - petgraph.add_edge(root, index, Edge::Prod(MarkerTree::TRUE)); + petgraph.add_edge(root, index, Edge::Prod); // Push the package onto the queue. roots.push((dist, index)); @@ -189,7 +188,7 @@ pub trait Installable<'lock> { // a specific marker environment and set of extras/groups. // So at this point, we know the extras/groups have been // satisfied, so we can safely drop the conflict marker. - Edge::Dev(group.clone(), dep.complexified_marker.pep508()), + Edge::Dev(group.clone()), ); // Push its dependencies on the queue. @@ -231,7 +230,7 @@ pub trait Installable<'lock> { inverse.insert(&dist.id, index); // Add the edge. - petgraph.add_edge(root, index, Edge::Prod(dependency.marker)); + petgraph.add_edge(root, index, Edge::Prod); // Push its dependencies on the queue. if seen.insert((&dist.id, None)) { @@ -300,7 +299,7 @@ pub trait Installable<'lock> { }; // Add the edge. - petgraph.add_edge(root, index, Edge::Dev(group.clone(), dependency.marker)); + petgraph.add_edge(root, index, Edge::Dev(group.clone())); // Push its dependencies on the queue. if seen.insert((&dist.id, None)) { @@ -484,9 +483,9 @@ pub trait Installable<'lock> { index, dep_index, if let Some(extra) = extra { - Edge::Optional(extra.clone(), dep.complexified_marker.pep508()) + Edge::Optional(extra.clone()) } else { - Edge::Prod(dep.complexified_marker.pep508()) + Edge::Prod }, ); diff --git a/crates/uv-resolver/src/resolution/output.rs b/crates/uv-resolver/src/resolution/output.rs index 928b9c605..dd2b3388f 100644 --- a/crates/uv-resolver/src/resolution/output.rs +++ b/crates/uv-resolver/src/resolution/output.rs @@ -894,16 +894,11 @@ impl From for uv_distribution_types::Resolution { // Re-add the edges to the reduced graph. for edge in graph.edge_indices() { let (source, target) = graph.edge_endpoints(edge).unwrap(); - // OK to ignore conflicting marker because we've asserted - // above that we aren't in universal mode. If we aren't in - // universal mode, then there can be no conflicts since - // conflicts imply forks and forks imply universal mode. - let marker = graph[edge].pep508(); match (&graph[source], &graph[target]) { (ResolutionGraphNode::Root, ResolutionGraphNode::Dist(target_dist)) => { let target = inverse[&target_dist.name()]; - transformed.update_edge(root, target, Edge::Prod(marker)); + transformed.update_edge(root, target, Edge::Prod); } ( ResolutionGraphNode::Dist(source_dist), @@ -913,11 +908,11 @@ impl From for uv_distribution_types::Resolution { let target = inverse[&target_dist.name()]; let edge = if let Some(extra) = source_dist.extra.as_ref() { - Edge::Optional(extra.clone(), marker) + Edge::Optional(extra.clone()) } else if let Some(dev) = source_dist.dev.as_ref() { - Edge::Dev(dev.clone(), marker) + Edge::Dev(dev.clone()) } else { - Edge::Prod(marker) + Edge::Prod }; transformed.add_edge(source, target, edge);