Skip to content

Commit

Permalink
move-build: Informative duplicate module error
Browse files Browse the repository at this point in the history
## Description
If we find a duplicate module when creating a `Modules` map, include the
module's ID in the output.

## Test plan
Hit this error when debugging something else.
  • Loading branch information
amnn committed Feb 13, 2025
1 parent 28bbe98 commit 7c4e5c1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions external-crates/move/crates/move-bytecode-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ impl<'a> Modules<'a> {
pub fn new(modules: impl IntoIterator<Item = &'a CompiledModule>) -> Self {
let mut map = BTreeMap::new();
for m in modules {
assert!(
map.insert(m.self_id(), m).is_none(),
"Duplicate module found"
);
if let Some(prev) = map.insert(m.self_id(), m) {
panic!(
"Duplicate module found: {}",
prev.self_id().to_canonical_display(/* with_prefix */ true)
)
}
}
Modules(map)
}
Expand Down

0 comments on commit 7c4e5c1

Please sign in to comment.