Skip to content

Commit 904ef98

Browse files
committed
cranelift: fix build warning
In bytecodealliance#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<V, StepError> { | -------------------------------------- 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 <rust-lang/rust#59159> ``` This change fixes the warning.
1 parent 3ea1813 commit 904ef98

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cranelift/interpreter/src/step.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ where
423423
}
424424
Opcode::GetPinnedReg => assign(state.get_pinned_reg()),
425425
Opcode::SetPinnedReg => {
426-
state.set_pinned_reg(arg(0)?);
426+
let arg0 = arg(0)?;
427+
state.set_pinned_reg(arg0);
427428
ControlFlow::Continue
428429
}
429430
Opcode::TableAddr => {

0 commit comments

Comments
 (0)