Fix a compiler warning.

Fix the following warning from Rust 1.35:

warning: cannot borrow `*self` as mutable because it is also borrowed as immutable
   --> wasmtime-runtime/src/instance.rs:473:25
    |
465 |         } else if let Some(start_export) = self.module.exports.get("_start") {
    |                                            ----------- immutable borrow occurs here
...
473 |                         self.invoke_function(*func_index)
    |                         ^^^^                 ----------- 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 commit is contained in:
Dan Gohman
2019-05-30 14:25:20 -07:00
parent b5f4949597
commit 825f1d764a

View File

@@ -466,11 +466,11 @@ impl Instance {
// As a compatibility measure, if the module doesn't have a start // As a compatibility measure, if the module doesn't have a start
// function but does have a _start function exported, call that. // function but does have a _start function exported, call that.
match start_export { match start_export {
wasmtime_environ::Export::Function(func_index) => { &wasmtime_environ::Export::Function(func_index) => {
let sig = &self.module.signatures[self.module.functions[*func_index]]; let sig = &self.module.signatures[self.module.functions[func_index]];
// No wasm params or returns; just the vmctx param. // No wasm params or returns; just the vmctx param.
if sig.params.len() == 1 && sig.returns.is_empty() { if sig.params.len() == 1 && sig.returns.is_empty() {
self.invoke_function(*func_index) self.invoke_function(func_index)
} else { } else {
Ok(()) Ok(())
} }
@@ -482,11 +482,11 @@ impl Instance {
// start function or a _start function exported, but does have a main // start function or a _start function exported, but does have a main
// function exported, call that. // function exported, call that.
match main_export { match main_export {
wasmtime_environ::Export::Function(func_index) => { &wasmtime_environ::Export::Function(func_index) => {
let sig = &self.module.signatures[self.module.functions[*func_index]]; let sig = &self.module.signatures[self.module.functions[func_index]];
// No wasm params or returns; just the vmctx param. // No wasm params or returns; just the vmctx param.
if sig.params.len() == 1 && sig.returns.is_empty() { if sig.params.len() == 1 && sig.returns.is_empty() {
self.invoke_function(*func_index) self.invoke_function(func_index)
} else { } else {
Ok(()) Ok(())
} }