Skip to content

Commit f450180

Browse files
Assert that there are no unused remappings.
1 parent 9bfa232 commit f450180

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

crates/cairo-lang-lowering/src/optimizations/reorder_statements.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::{
2121
///
2222
/// The list of call statements that can be moved is currently hardcoded.
2323
///
24-
/// Removing unnecessary remapping before this optimization will result in better code.
24+
/// Unused remapping should be removed before running this optimization (using `optimize_remappings`).
2525
pub fn reorder_statements(db: &dyn LoweringGroup, lowered: &mut FlatLowered) {
2626
if lowered.blocks.is_empty() {
2727
return;
@@ -152,8 +152,9 @@ impl Analyzer<'_> for ReorderStatementsContext<'_> {
152152
_target_block_id: BlockId,
153153
remapping: &VarRemapping,
154154
) {
155-
for VarUsage { var_id, .. } in remapping.values() {
156-
info.next_use.insert(*var_id, statement_location);
155+
for (dst, src) in remapping.iter() {
156+
assert!(info.next_use.contains_key(dst), "Unused remappings should be removed before running this optimization.");
157+
info.next_use.insert(src.var_id, statement_location);
157158
}
158159
}
159160

0 commit comments

Comments
 (0)