Unverified Commit 03dc2558 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: add debug assertion to check for duplicate modules (#78025)

### What?

Quick debug check to panic for duplicate modules
parent 3220f1f0
...@@ -325,6 +325,21 @@ impl SingleModuleGraph { ...@@ -325,6 +325,21 @@ impl SingleModuleGraph {
graph.shrink_to_fit(); graph.shrink_to_fit();
#[cfg(debug_assertions)]
{
let mut duplicates = Vec::new();
let mut set = FxHashSet::default();
for &module in modules.keys() {
let ident = module.ident().to_string().await?;
if !set.insert(ident.clone()) {
duplicates.push(ident);
}
}
if !duplicates.is_empty() {
panic!("Duplicate module idents in graph: {:#?}", duplicates);
}
}
Ok(SingleModuleGraph { Ok(SingleModuleGraph {
graph: TracedDiGraph::new(graph), graph: TracedDiGraph::new(graph),
number_of_modules, number_of_modules,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment