Repository: mun-lang/mun (language: rust)

Issue:
failed to select a version for the requirement `wasmer-runtime = "^0.16"`
Fresh builds fail with:

```
failed to select a version for the requirement `wasmer-runtime = "^0.16"`
```

This is because all pre 1.0 `wasmer-runtime`  versions have been yanked and the `wasmer-runtime` has been deprecated in favor of `wasmer`.

https://crates.io/crates/wasmer-runtime


Discussion / hints:

Fix patch:
diff --git a/crates/mun_runtime/Cargo.toml b/crates/mun_runtime/Cargo.toml
index cf7d5b175..c5239f4f6 100644
--- a/crates/mun_runtime/Cargo.toml
+++ b/crates/mun_runtime/Cargo.toml
@@ -33,7 +33,7 @@ mlua = { package ="mlua", version="0.2", default-features = false, features=["ve
 mun_test = { path = "../mun_test" }
 tempfile = "3"
 termcolor = "1.1"
-wasmer-runtime = "0.16"
+wasmer = "2.2.1"
 
 [[bench]]
 name = "benchmarks"
diff --git a/crates/mun_runtime/benches/benchmarks.rs b/crates/mun_runtime/benches/benchmarks.rs
index 177580655..036da1a52 100644
--- a/crates/mun_runtime/benches/benchmarks.rs
+++ b/crates/mun_runtime/benches/benchmarks.rs
@@ -1,5 +1,6 @@
 use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
 use mun_runtime::StructRef;
+use wasmer::Store;
 
 mod util;
 
@@ -9,7 +10,9 @@ pub fn fibonacci_benchmark(c: &mut Criterion) {
     // Perform setup (not part of the benchmark)
     let runtime = util::runtime_from_file("fibonacci.mun");
     let lua = util::lua_from_file("fibonacci.lua");
-    let wasm = util::wasmer_from_file("fibonacci.wasm");
+    let wasm_store = Store::default();
+    let wasm = util::wasmer_from_file(&wasm_store, "fibonacci.wasm");
+    let wasm_func = wasm.exports.get_function("main").unwrap();
 
     let mut group = c.benchmark_group("fibonacci");
 
@@ -38,7 +41,7 @@ pub fn fibonacci_benchmark(c: &mut Criterion) {
         // Run Wasm fibonacci
         group.bench_with_input(BenchmarkId::new("wasm", i), i, |b, i| {
             b.iter(|| {
-                wasm.call("main", &[(*i as i32).into()]).unwrap();
+                wasm_func.call(&[(*i as i32).into()]).unwrap();
             })
         });
     }
@@ -72,7 +75,9 @@ pub fn empty_benchmark(c: &mut Criterion) {
     // Perform setup (not part of the benchmark)
     let runtime = util::runtime_from_file("empty.mun");
     let lua = util::lua_from_file("empty.lua");
-    let wasm = util::wasmer_from_file("empty.wasm");
+    let wasm_store = Store::default();
+    let wasm = util::wasmer_from_file(&wasm_store, "empty.wasm");
+    let wasm_func = wasm.exports.get_function("empty").unwrap();
 
     let mut group = c.benchmark_group("empty");
 
@@ -89,7 +94,7 @@ pub fn empty_benchmark(c: &mut Criterion) {
         })
     });
     group.bench_function("wasm", |b| {
-        b.iter(|| wasm.call("empty", &[black_box(20i64).into()]))
+        b.iter(|| wasm_func.call(&[black_box(20i64).into()]))
     });
 
     group.finish();
diff --git a/crates/mun_runtime/benches/util/mod.rs b/crates/mun_runtime/benches/util/mod.rs
index 1e16d5f9f..2bc01543b 100644
--- a/crates/mun_runtime/benches/util/mod.rs
+++ b/crates/mun_runtime/benches/util/mod.rs
@@ -2,7 +2,7 @@ use compiler::{Config, DisplayColor, Driver, OptimizationLevel, PathOrInline};
 use mlua::Lua;
 use mun_runtime::Runtime;
 use std::path::{Path, PathBuf};
-use wasmer_runtime::{instantiate, Instance};
+use wasmer::{Instance, Module, Store};
 
 fn compute_resource_path<P: AsRef<Path>>(p: P) -> PathBuf {
     PathBuf::from(env!("CARGO_MANIFEST_DIR"))
@@ -40,8 +40,9 @@ pub fn lua_from_file<P: AsRef<Path>>(p: P) -> Lua {
     lua
 }
 
-pub fn wasmer_from_file<P: AsRef<Path>>(p: P) -> Instance {
+pub fn wasmer_from_file<P: AsRef<Path>>(store: &Store, p: P) -> Instance {
     let wasm_content = std::fs::read(compute_resource_path(p)).unwrap();
-    let import_objects = wasmer_runtime::imports! {};
-    instantiate(&wasm_content, &import_objects).unwrap()
+    let import_objects = wasmer::imports! {};
+    let module = Module::new(store, &wasm_content).unwrap();
+    Instance::new(&module, &import_objects).unwrap()
 }


Test patch: