22use crate :: component;
33use crate :: core;
44use crate :: spectest:: * ;
5- use anyhow:: { Context as _, anyhow, bail} ;
65use json_from_wast:: { Action , Command , Const , WasmFile , WasmFileType } ;
76use std:: collections:: HashMap ;
87use std:: path:: { Path , PathBuf } ;
98use std:: str;
109use std:: sync:: Arc ;
1110use std:: thread;
12- use wasmtime:: * ;
11+ use wasmtime:: { error :: Context as _ , * } ;
1312use wast:: lexer:: Lexer ;
1413use wast:: parser:: { self , ParseBuffer } ;
1514
@@ -172,24 +171,24 @@ impl WastContext {
172171 return Ok ( Export :: Core (
173172 self . core_linker
174173 . get ( & mut self . core_store , module, name)
175- . ok_or_else ( || anyhow ! ( "no item named `{module}::{name}` found" ) ) ?,
174+ . ok_or_else ( || format_err ! ( "no item named `{module}::{name}` found" ) ) ?,
176175 ) ) ;
177176 }
178177
179178 let cur = self
180179 . current
181180 . as_mut ( )
182- . ok_or_else ( || anyhow ! ( "no previous instance found" ) ) ?;
181+ . ok_or_else ( || format_err ! ( "no previous instance found" ) ) ?;
183182 Ok ( match cur {
184183 InstanceKind :: Core ( i) => Export :: Core (
185184 i. get_export ( & mut self . core_store , name)
186- . ok_or_else ( || anyhow ! ( "no item named `{name}` found" ) ) ?,
185+ . ok_or_else ( || format_err ! ( "no item named `{name}` found" ) ) ?,
187186 ) ,
188187 #[ cfg( feature = "component-model" ) ]
189188 InstanceKind :: Component ( store, i) => {
190189 let export = i
191190 . get_func ( & mut * store, name)
192- . ok_or_else ( || anyhow ! ( "no func named `{name}` found" ) ) ?;
191+ . ok_or_else ( || format_err ! ( "no func named `{name}` found" ) ) ?;
193192 Export :: Component ( store, export)
194193 }
195194 } )
@@ -267,7 +266,7 @@ impl WastContext {
267266 drop ( replace) ;
268267 let func = export
269268 . into_func ( )
270- . ok_or_else ( || anyhow ! ( "no function named `{field}`" ) ) ?;
269+ . ok_or_else ( || format_err ! ( "no function named `{field}`" ) ) ?;
271270 let values = args
272271 . iter ( )
273272 . map ( |v| match v {
@@ -390,7 +389,7 @@ impl WastContext {
390389 WasmFileType :: Text => file
391390 . binary_filename
392391 . as_ref ( )
393- . ok_or_else ( || anyhow ! ( "cannot compile module that isn't a valid binary" ) ) ?,
392+ . ok_or_else ( || format_err ! ( "cannot compile module that isn't a valid binary" ) ) ?,
394393 WasmFileType :: Binary => & file. filename ,
395394 } ;
396395
@@ -445,7 +444,7 @@ impl WastContext {
445444 let current = self
446445 . current
447446 . as_ref ( )
448- . ok_or ( anyhow ! ( "no previous instance" ) ) ?;
447+ . ok_or ( format_err ! ( "no previous instance" ) ) ?;
449448 match current {
450449 InstanceKind :: Core ( current) => {
451450 self . core_linker
@@ -466,7 +465,7 @@ impl WastContext {
466465 let global = match self . get_export ( instance_name, field) ? {
467466 Export :: Core ( e) => e
468467 . into_global ( )
469- . ok_or_else ( || anyhow ! ( "no global named `{field}`" ) ) ?,
468+ . ok_or_else ( || format_err ! ( "no global named `{field}`" ) ) ?,
470469 #[ cfg( feature = "component-model" ) ]
471470 Export :: Component ( ..) => bail ! ( "no global named `{field}`" ) ,
472471 } ;
@@ -651,7 +650,7 @@ impl WastContext {
651650 . as_deref ( )
652651 . and_then ( |n| self . modules . get ( n) )
653652 . cloned ( )
654- . ok_or_else ( || anyhow ! ( "no module named {module:?}" ) ) ?;
653+ . ok_or_else ( || format_err ! ( "no module named {module:?}" ) ) ?;
655654 self . module ( instance. as_deref ( ) , & module) ?;
656655 }
657656 Register { line : _, name, as_ } => {
@@ -788,7 +787,7 @@ impl WastContext {
788787 Wait { thread, .. } => {
789788 threads
790789 . remove ( & thread[ ..] )
791- . ok_or_else ( || anyhow ! ( "no thread named `{thread}`" ) ) ?
790+ . ok_or_else ( || format_err ! ( "no thread named `{thread}`" ) ) ?
792791 . join ( )
793792 . unwrap ( ) ?;
794793 }
0 commit comments