Skip to content

Commit 76a4c53

Browse files
committed
re-format assert-instr changes
1 parent 2dae59d commit 76a4c53

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

crates/assert-instr-macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub fn assert_instr(
119119
// If instruction tests are disabled avoid emitting this shim at all, just
120120
// return the original item without our attribute.
121121
if !cfg!(optimized) || disable_assert_instr {
122-
return (quote! { #item }).into()
122+
return (quote! { #item }).into();
123123
}
124124

125125
let tts: TokenStream = quote! {

crates/stdsimd-test/src/lib.rs

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,20 @@ fn parse_dumpbin(output: &str) -> HashMap<String, Vec<Function>> {
259259
}
260260

261261
#[wasm_bindgen(module = "child_process", version = "*")]
262-
extern {
262+
extern "C" {
263263
#[wasm_bindgen(js_name = execSync)]
264264
fn exec_sync(cmd: &str) -> Buffer;
265265
}
266266

267267
#[wasm_bindgen(module = "buffer", version = "*")]
268-
extern {
268+
extern "C" {
269269
type Buffer;
270270
#[wasm_bindgen(method, js_name = toString)]
271271
fn to_string(this: &Buffer) -> String;
272272
}
273273

274274
#[wasm_bindgen]
275-
extern {
275+
extern "C" {
276276
#[wasm_bindgen(js_namespace = require)]
277277
fn resolve(module: &str) -> String;
278278
#[wasm_bindgen(js_namespace = console, js_name = log)]
@@ -292,32 +292,31 @@ fn parse_wasm2wat() -> HashMap<String, Vec<Function>> {
292292
// file. Ask node where that JS file is, and then we use that with a wasm
293293
// extension to find the wasm file itself.
294294
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");
297296

298297
// Execute `wasm2wat` synchronously, waiting for and capturing all of its
299298
// 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();
302301

303302
let mut ret: HashMap<String, Vec<Function>> = HashMap::new();
304303
let mut lines = output.lines().map(|s| s.trim());
305304
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
308307
if line.starts_with("(elem") {
309308
for (i, name) in line.split_whitespace().skip(3).enumerate() {
310309
let name = name.trim_right_matches(")");
311310
for f in ret.get_mut(name).unwrap() {
312311
f.addr = Some(i + 1);
313312
}
314313
}
315-
continue
314+
continue;
316315
}
317316

318317
// If this isn't a function, we don't care about it.
319318
if !line.starts_with("(func ") {
320-
continue
319+
continue;
321320
}
322321

323322
let mut function = Function {
@@ -332,21 +331,24 @@ fn parse_wasm2wat() -> HashMap<String, Vec<Function>> {
332331
if !line.ends_with("))") {
333332
while let Some(line) = lines.next() {
334333
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(),
336338
});
337339
if !line.starts_with("(") && line.ends_with(")") {
338-
break
340+
break;
339341
}
340342
}
341343
}
342344

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
345347
ret.entry(line.split_whitespace().nth(1).unwrap().to_string())
346348
.or_insert(Vec::new())
347349
.push(function);
348350
}
349-
return ret
351+
return ret;
350352
}
351353

352354
fn normalize(symbol: &str) -> String {
@@ -364,9 +366,12 @@ fn normalize(symbol: &str) -> String {
364366
pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
365367
// The string in expected is surrounded by '"', strip these:
366368
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()
370375
};
371376
let mut fnname = fnname.to_string();
372377
let functions = get_functions(fnptr, &mut fnname);
@@ -452,10 +457,7 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
452457

453458
// Help debug by printing out the found disassembly, and then panic as we
454459
// didn't find the instruction.
455-
println!(
456-
"disassembly for {}: ",
457-
fnname,
458-
);
460+
println!("disassembly for {}: ", fnname,);
459461
for (i, instr) in instrs.iter().enumerate() {
460462
let mut s = format!("\t{:2}: ", i);
461463
for part in &instr.parts {
@@ -496,16 +498,16 @@ fn get_functions(fnptr: usize, fnname: &mut String) -> &'static [Function] {
496498
if let Some(sym) = &sym {
497499
if let Some(s) = DISASSEMBLY.get(sym) {
498500
*fnname = sym.to_string();
499-
return s
501+
return s;
500502
}
501503
}
502504

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)));
506508
if let Some((name, list)) = exact_match {
507509
*fnname = name.to_string();
508-
return list
510+
return list;
509511
}
510512

511513
if let Some(sym) = sym {
@@ -518,7 +520,6 @@ fn get_functions(fnptr: usize, fnname: &mut String) -> &'static [Function] {
518520
panic!("failed to find disassembly of {:#x} ({})", fnptr, fnname);
519521
}
520522

521-
522523
pub fn assert_skip_test_ok(name: &str) {
523524
if env::var("STDSIMD_TEST_EVERYTHING").is_err() {
524525
return;

0 commit comments

Comments
 (0)