From a83c50321fad140e252bf6adb628be8114cbf740 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 11 Aug 2022 16:52:00 -0700 Subject: [PATCH] cranelift: fix build warning (#4698) In #4375 we introduced a code pattern that appears as a warning when building the `cranelift-interpreter` crate: ``` warning: cannot borrow `*state` as mutable because it is also borrowed as immutable --> cranelift/interpreter/src/step.rs:412:13 | 47 | let arg = |index: usize| -> Result { | -------------------------------------- immutable borrow occurs here 48 | let value_ref = inst_context.args()[index]; 49 | state | ----- first borrow occurs due to use of `*state` in closure ... 412 | state.set_pinned_reg(arg(0)?); | ^^^^^^^^^^^^^^^^^^^^^---^^^^^ | | | | | immutable borrow later used here | mutable borrow occurs here | = note: `#[warn(mutable_borrow_reservation_conflict)]` on by default = warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future = note: for more information, see issue #59159 ``` This change fixes the warning. --- cranelift/interpreter/src/step.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cranelift/interpreter/src/step.rs b/cranelift/interpreter/src/step.rs index 87c86409de5d..8860c924e25a 100644 --- a/cranelift/interpreter/src/step.rs +++ b/cranelift/interpreter/src/step.rs @@ -423,7 +423,8 @@ where } Opcode::GetPinnedReg => assign(state.get_pinned_reg()), Opcode::SetPinnedReg => { - state.set_pinned_reg(arg(0)?); + let arg0 = arg(0)?; + state.set_pinned_reg(arg0); ControlFlow::Continue } Opcode::TableAddr => {