Skip to content

Commit e84c33a

Browse files
author
Arnaud Riess
committed
refactor: fixed clippy warning
1 parent 6c6d2e7 commit e84c33a

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

crates/herkos/src/optimizer/copy_prop.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ fn forward_propagate_one(block: &mut IrBlock, global_uses: &HashMap<VarId, usize
437437
.enumerate()
438438
.filter(|(_, i)| count_uses_of(i, v_dst) > 0)
439439
.map(|(rel, _)| assign_idx + 1 + rel)
440-
.last()
440+
.next_back()
441441
.unwrap_or(assign_idx) // unreachable: local_uses_after > 0
442442
};
443443

@@ -515,7 +515,9 @@ fn replace_uses_of(instr: &mut IrInstr, old: VarId, new: VarId) {
515515
sub(a);
516516
}
517517
}
518-
IrInstr::CallIndirect { table_idx, args, .. } => {
518+
IrInstr::CallIndirect {
519+
table_idx, args, ..
520+
} => {
519521
sub(table_idx);
520522
for a in args {
521523
sub(a);
@@ -1015,7 +1017,11 @@ mod tests {
10151017
},
10161018
));
10171019
eliminate(&mut func);
1018-
assert_eq!(func.blocks[0].instructions.len(), 0, "Assign should be removed");
1020+
assert_eq!(
1021+
func.blocks[0].instructions.len(),
1022+
0,
1023+
"Assign should be removed"
1024+
);
10191025
match &func.blocks[0].terminator {
10201026
IrTerminator::Return { value: Some(v) } => assert_eq!(*v, VarId(0)),
10211027
other => panic!("expected Return(v0), got {other:?}"),
@@ -1052,7 +1058,10 @@ mod tests {
10521058
assert_eq!(func.blocks[0].instructions.len(), 1);
10531059
assert!(matches!(
10541060
func.blocks[0].instructions[0],
1055-
IrInstr::Assign { dest: VarId(10), src: VarId(0) }
1061+
IrInstr::Assign {
1062+
dest: VarId(10),
1063+
src: VarId(0)
1064+
}
10561065
));
10571066
}
10581067

@@ -1189,7 +1198,12 @@ mod tests {
11891198
let instrs = &func.blocks[0].instructions;
11901199
assert_eq!(instrs.len(), 1, "both Assigns should be removed");
11911200
match &instrs[0] {
1192-
IrInstr::BinOp { lhs, rhs, op: BinOp::I32GeS, .. } => {
1201+
IrInstr::BinOp {
1202+
lhs,
1203+
rhs,
1204+
op: BinOp::I32GeS,
1205+
..
1206+
} => {
11931207
assert_eq!(*lhs, VarId(1), "lhs should be v1");
11941208
assert_eq!(*rhs, VarId(0), "rhs should be v0");
11951209
}
@@ -1259,7 +1273,11 @@ mod tests {
12591273

12601274
let instrs = &func.blocks[0].instructions;
12611275
// Only the 3 BinOps remain; all 4 Assigns are gone.
1262-
assert_eq!(instrs.len(), 3, "all 4 Assigns should be removed, leaving 3 BinOps");
1276+
assert_eq!(
1277+
instrs.len(),
1278+
3,
1279+
"all 4 Assigns should be removed, leaving 3 BinOps"
1280+
);
12631281

12641282
// v23 = BinOp(I32LtS, v1, v0)
12651283
match &instrs[0] {

0 commit comments

Comments
 (0)