From 9d750257c42b97e04019001a40ee2cf7c4ca4012 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 21 Sep 2023 15:53:05 +0200 Subject: [PATCH 1/2] Fix unjustified assumption of same lifetime --- crates/ir/src/function.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/ir/src/function.rs b/crates/ir/src/function.rs index 117bd8cd..df0bbf77 100644 --- a/crates/ir/src/function.rs +++ b/crates/ir/src/function.rs @@ -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 { From 3d27abc5d372761bcb5334eaa37296a9d3a3fe3a Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 21 Sep 2023 15:53:29 +0200 Subject: [PATCH 2/2] Use opaque reference --- crates/ir/src/insn.rs | 2 +- crates/ir/src/module.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ir/src/insn.rs b/crates/ir/src/insn.rs index 9635bb1d..5aa8e769 100644 --- a/crates/ir/src/insn.rs +++ b/crates/ir/src/insn.rs @@ -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) diff --git a/crates/ir/src/module.rs b/crates/ir/src/module.rs index c9bef630..5e68d721 100644 --- a/crates/ir/src/module.rs +++ b/crates/ir/src/module.rs @@ -91,12 +91,12 @@ 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 } } } @@ -104,7 +104,7 @@ impl<'a> DisplayCalleeFuncRef<'a> { 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()) } }