Skip to content

Commit 46944a4

Browse files
committed
feedback: derive Ord instead
1 parent af4370e commit 46944a4

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

turbopack/crates/turbopack-core/src/module_graph/merged_modules.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{cmp::Ordering, collections::hash_map::Entry};
1+
use std::collections::hash_map::Entry;
22

33
use anyhow::{Context, Result, bail};
44
use rustc_hash::{FxHashMap, FxHashSet};
@@ -185,23 +185,12 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
185185

186186
span.record("visit_count", visit_count);
187187

188-
#[derive(Debug, PartialEq, Eq, Hash)]
188+
#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
189189
struct ListOccurence {
190-
list: usize,
190+
// The field order here is important, these structs will get ordered by the entry
191+
// index.
191192
entry: usize,
192-
}
193-
impl PartialOrd for ListOccurence {
194-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
195-
Some(self.cmp(other))
196-
}
197-
}
198-
impl Ord for ListOccurence {
199-
fn cmp(&self, other: &Self) -> Ordering {
200-
self.entry
201-
.cmp(&other.entry)
202-
// don't matter but needed to make it a total ordering
203-
.then_with(|| self.list.cmp(&other.list))
204-
}
193+
list: usize,
205194
}
206195

207196
// A list of all different execution traces (orderings) of all modules, initially a union of

0 commit comments

Comments
 (0)