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<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 <https://github.com/rust-lang/rust/issues/59159>
```

This change fixes the warning.
This commit is contained in:
Andrew Brown
2022-08-11 16:52:00 -07:00
committed by GitHub
parent 2be15ab814
commit a83c50321f

View File

@@ -423,7 +423,8 @@ where
} }
Opcode::GetPinnedReg => assign(state.get_pinned_reg()), Opcode::GetPinnedReg => assign(state.get_pinned_reg()),
Opcode::SetPinnedReg => { Opcode::SetPinnedReg => {
state.set_pinned_reg(arg(0)?); let arg0 = arg(0)?;
state.set_pinned_reg(arg0);
ControlFlow::Continue ControlFlow::Continue
} }
Opcode::TableAddr => { Opcode::TableAddr => {