Skip to content

Commit

Permalink
Avoid new assign
Browse files Browse the repository at this point in the history
  • Loading branch information
k0aki committed Aug 14, 2023
1 parent 327e706 commit 9aff428
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions crates/ir/src/insn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ impl<'a> fmt::Display for DisplayInsn<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Self { insn, func } = *self;

let display_result = DisplayResultValue::new(insn, &func.dfg);
write!(f, "{display_result}")?;
let result = DisplayResultValue::new(insn, &func.dfg);
write!(f, "{result}")?;

let display_insn = DisplayInsnData::new(insn, func);
write!(f, "{display_insn}")
let insn = DisplayInsnData::new(insn, func);
write!(f, "{insn}")
}
}

Expand Down Expand Up @@ -489,8 +489,8 @@ impl<'a> fmt::Display for DisplayInsnData<'a> {
write!(f, " {};", table[table.len() - 1])
}
Alloca { ty } => {
let display_ty = DisplayType::new(*ty, dfg);
write!(f, "alloca {display_ty};")
let ty = DisplayType::new(*ty, dfg);
write!(f, "alloca {ty};")
}
Return { args } => {
write!(f, "ret")?;
Expand Down
8 changes: 4 additions & 4 deletions crates/ir/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ impl<'a> fmt::Display for DisplayCompoundType<'a> {
dfg.ctx
.with_ty_store(|s| match s.resolve_compound(self.cmpd_ty) {
Array { elem: ty, len } => {
let display_ty = DisplayType::new(*ty, dfg);
write!(f, "[{display_ty};{len}]")
let ty = DisplayType::new(*ty, dfg);
write!(f, "[{ty};{len}]")
}
Ptr(ty) => {
let display_ty = DisplayType::new(*ty, dfg);
write!(f, "*{display_ty}")
let ty = DisplayType::new(*ty, dfg);
write!(f, "*{ty}")
}
Struct(StructData { name, packed, .. }) => {
if *packed {
Expand Down
8 changes: 4 additions & 4 deletions crates/ir/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ impl<'a> fmt::Display for DisplayResultValue<'a> {
let Self { insn, dfg } = *self;
if let Some(value) = dfg.insn_result(insn) {
let ty = dfg.insn_result_ty(insn).unwrap();
let display_ty = DisplayType::new(ty, dfg);
return write!(f, "v{}.{display_ty} = ", value.0);
let ty = DisplayType::new(ty, dfg);
return write!(f, "v{}.{ty} = ", value.0);
}
Ok(())
}
Expand All @@ -48,8 +48,8 @@ impl<'a, 'b> DisplayArgValues<'a, 'b> {
let dfg = self.dfg;
match *dfg.value_data(*arg) {
ValueData::Immediate { imm, ty } => {
let display_ty = DisplayType::new(ty, dfg);
write!(w, "{imm}.{display_ty}")
let ty = DisplayType::new(ty, dfg);
write!(w, "{imm}.{ty}")
}
_ => write!(w, "v{}", arg.0),
}
Expand Down

0 comments on commit 9aff428

Please sign in to comment.