Skip to content

Commit

Permalink
Merge pull request #32 from k0aki/fix-lifetime-bug
Browse files Browse the repository at this point in the history
Fix lifetime bug
  • Loading branch information
Y-Nak authored Sep 28, 2023
2 parents e8679cd + 3d27abc commit 963ecd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions crates/ir/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ impl Signature {
}
}

pub struct DisplaySignature<'a> {
pub struct DisplaySignature<'a, 'b> {
sig: &'a Signature,
dfg: &'a DataFlowGraph,
dfg: &'b DataFlowGraph,
}

impl<'a> DisplaySignature<'a> {
pub fn new(sig: &'a Signature, dfg: &'a DataFlowGraph) -> Self {
impl<'a, 'b> DisplaySignature<'a, 'b> {
pub fn new(sig: &'a Signature, dfg: &'b DataFlowGraph) -> Self {
Self { sig, dfg }
}
}

impl<'a> fmt::Display for DisplaySignature<'a> {
impl<'a, 'b> fmt::Display for DisplaySignature<'a, 'b> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Self { sig, dfg } = *self;
let Signature {
Expand Down
2 changes: 1 addition & 1 deletion crates/ir/src/insn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ impl<'a> fmt::Display for DisplayInsnData<'a> {
Call {
args, func: callee, ..
} => {
let callee = DisplayCalleeFuncRef::new(callee, func);
let callee = DisplayCalleeFuncRef::new(*callee, func);
write!(f, "call %{callee} ")?;
display_arg_values(f, args, dfg)?;
";".fmt(f)
Expand Down
6 changes: 3 additions & 3 deletions crates/ir/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ pub struct FuncRef(u32);
entity_impl!(FuncRef);

pub struct DisplayCalleeFuncRef<'a> {
callee: &'a FuncRef,
callee: FuncRef,
func: &'a Function,
}

impl<'a> DisplayCalleeFuncRef<'a> {
pub fn new(callee: &'a FuncRef, func: &'a Function) -> Self {
pub fn new(callee: FuncRef, func: &'a Function) -> Self {
Self { callee, func }
}
}

impl<'a> fmt::Display for DisplayCalleeFuncRef<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Self { callee, func } = *self;
let sig = func.callees.get(callee).unwrap();
let sig = func.callees.get(&callee).unwrap();
write!(f, "{}", sig.name())
}
}

0 comments on commit 963ecd8

Please sign in to comment.