@@ -259,20 +259,20 @@ fn parse_dumpbin(output: &str) -> HashMap<String, Vec<Function>> {
259
259
}
260
260
261
261
#[ wasm_bindgen( module = "child_process" , version = "*" ) ]
262
- extern {
262
+ extern "C" {
263
263
#[ wasm_bindgen( js_name = execSync) ]
264
264
fn exec_sync ( cmd : & str ) -> Buffer ;
265
265
}
266
266
267
267
#[ wasm_bindgen( module = "buffer" , version = "*" ) ]
268
- extern {
268
+ extern "C" {
269
269
type Buffer ;
270
270
#[ wasm_bindgen( method, js_name = toString) ]
271
271
fn to_string ( this : & Buffer ) -> String ;
272
272
}
273
273
274
274
#[ wasm_bindgen]
275
- extern {
275
+ extern "C" {
276
276
#[ wasm_bindgen( js_namespace = require) ]
277
277
fn resolve ( module : & str ) -> String ;
278
278
#[ wasm_bindgen( js_namespace = console, js_name = log) ]
@@ -292,32 +292,31 @@ fn parse_wasm2wat() -> HashMap<String, Vec<Function>> {
292
292
// file. Ask node where that JS file is, and then we use that with a wasm
293
293
// extension to find the wasm file itself.
294
294
let js_shim = resolve ( "wasm-bindgen-test_bg" ) ;
295
- let js_shim = Path :: new ( & js_shim)
296
- . with_extension ( "wasm" ) ;
295
+ let js_shim = Path :: new ( & js_shim) . with_extension ( "wasm" ) ;
297
296
298
297
// Execute `wasm2wat` synchronously, waiting for and capturing all of its
299
298
// output.
300
- let output = exec_sync ( & format ! ( "wasm2wat {}" , js_shim . display ( ) ) )
301
- . to_string ( ) ;
299
+ let output =
300
+ exec_sync ( & format ! ( "wasm2wat {}" , js_shim . display ( ) ) ) . to_string ( ) ;
302
301
303
302
let mut ret: HashMap < String , Vec < Function > > = HashMap :: new ( ) ;
304
303
let mut lines = output. lines ( ) . map ( |s| s. trim ( ) ) ;
305
304
while let Some ( line) = lines. next ( ) {
306
- // If we found the table of function pointers, fill in the known address
307
- // for all our `Function` instances
305
+ // If we found the table of function pointers, fill in the known
306
+ // address for all our `Function` instances
308
307
if line. starts_with ( "(elem" ) {
309
308
for ( i, name) in line. split_whitespace ( ) . skip ( 3 ) . enumerate ( ) {
310
309
let name = name. trim_right_matches ( ")" ) ;
311
310
for f in ret. get_mut ( name) . unwrap ( ) {
312
311
f. addr = Some ( i + 1 ) ;
313
312
}
314
313
}
315
- continue
314
+ continue ;
316
315
}
317
316
318
317
// If this isn't a function, we don't care about it.
319
318
if !line. starts_with ( "(func " ) {
320
- continue
319
+ continue ;
321
320
}
322
321
323
322
let mut function = Function {
@@ -332,21 +331,24 @@ fn parse_wasm2wat() -> HashMap<String, Vec<Function>> {
332
331
if !line. ends_with ( "))" ) {
333
332
while let Some ( line) = lines. next ( ) {
334
333
function. instrs . push ( Instruction {
335
- parts : line. split_whitespace ( ) . map ( |s| s. to_string ( ) ) . collect ( ) ,
334
+ parts : line
335
+ . split_whitespace ( )
336
+ . map ( |s| s. to_string ( ) )
337
+ . collect ( ) ,
336
338
} ) ;
337
339
if !line. starts_with ( "(" ) && line. ends_with ( ")" ) {
338
- break
340
+ break ;
339
341
}
340
342
}
341
343
}
342
344
343
- // The second element here split on whitespace should be the name of the
344
- // function, skipping the type/params/results
345
+ // The second element here split on whitespace should be the name of
346
+ // the function, skipping the type/params/results
345
347
ret. entry ( line. split_whitespace ( ) . nth ( 1 ) . unwrap ( ) . to_string ( ) )
346
348
. or_insert ( Vec :: new ( ) )
347
349
. push ( function) ;
348
350
}
349
- return ret
351
+ return ret;
350
352
}
351
353
352
354
fn normalize ( symbol : & str ) -> String {
@@ -364,9 +366,12 @@ fn normalize(symbol: &str) -> String {
364
366
pub fn assert ( fnptr : usize , fnname : & str , expected : & str ) {
365
367
// The string in expected is surrounded by '"', strip these:
366
368
let expected = {
367
- assert ! ( expected. len( ) > 2 && expected. starts_with( '"' )
368
- && expected. ends_with( '"' ) ) ;
369
- expected. get ( 1 ..expected. len ( ) -1 ) . unwrap ( )
369
+ assert ! (
370
+ expected. len( ) > 2
371
+ && expected. starts_with( '"' )
372
+ && expected. ends_with( '"' )
373
+ ) ;
374
+ expected. get ( 1 ..expected. len ( ) - 1 ) . unwrap ( )
370
375
} ;
371
376
let mut fnname = fnname. to_string ( ) ;
372
377
let functions = get_functions ( fnptr, & mut fnname) ;
@@ -452,10 +457,7 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
452
457
453
458
// Help debug by printing out the found disassembly, and then panic as we
454
459
// didn't find the instruction.
455
- println ! (
456
- "disassembly for {}: " ,
457
- fnname,
458
- ) ;
460
+ println ! ( "disassembly for {}: " , fnname, ) ;
459
461
for ( i, instr) in instrs. iter ( ) . enumerate ( ) {
460
462
let mut s = format ! ( "\t {:2}: " , i) ;
461
463
for part in & instr. parts {
@@ -496,16 +498,16 @@ fn get_functions(fnptr: usize, fnname: &mut String) -> &'static [Function] {
496
498
if let Some ( sym) = & sym {
497
499
if let Some ( s) = DISASSEMBLY . get ( sym) {
498
500
* fnname = sym. to_string ( ) ;
499
- return s
501
+ return s;
500
502
}
501
503
}
502
504
503
- let exact_match = DISASSEMBLY . iter ( ) . find ( | ( _ , list ) | {
504
- list . iter ( ) . any ( |f| f . addr == Some ( fnptr ) )
505
- } ) ;
505
+ let exact_match = DISASSEMBLY
506
+ . iter ( )
507
+ . find ( | ( _ , list ) | list . iter ( ) . any ( |f| f . addr == Some ( fnptr ) ) ) ;
506
508
if let Some ( ( name, list) ) = exact_match {
507
509
* fnname = name. to_string ( ) ;
508
- return list
510
+ return list;
509
511
}
510
512
511
513
if let Some ( sym) = sym {
@@ -518,7 +520,6 @@ fn get_functions(fnptr: usize, fnname: &mut String) -> &'static [Function] {
518
520
panic ! ( "failed to find disassembly of {:#x} ({})" , fnptr, fnname) ;
519
521
}
520
522
521
-
522
523
pub fn assert_skip_test_ok ( name : & str ) {
523
524
if env:: var ( "STDSIMD_TEST_EVERYTHING" ) . is_err ( ) {
524
525
return ;
0 commit comments