Skip to content

Commit 9130158

Browse files
committed
fix CI errors in wasm-bindgen
1 parent 718b6fe commit 9130158

File tree

7 files changed

+29
-33
lines changed

7 files changed

+29
-33
lines changed

.cargo/config.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
runner = 'cargo run -p wasm-bindgen-cli --bin wasm-bindgen-test-runner --'
33

44
[build]
5+
56
[target.'cfg(all(target_arch = "wasm32", target_os = "emscripten"))']
67
rustflags = [
7-
"-Cllvm-args=-enable-emscripten-cxx-exceptions=0",
8-
"-Clink-arg=-Wno-undefined",
9-
"-Crelocation-model=static",
8+
"-Cllvm-args=-enable-emscripten-cxx-exceptions=0",
9+
"-Clink-arg=-Wno-undefined",
10+
"-Crelocation-model=static",
1011
]

crates/cli-support/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ version = "0.2.100"
1717
anyhow = "1.0"
1818
base64 = "0.22"
1919
log = "0.4"
20+
regex = "1"
2021
rustc-demangle = "0.1.13"
2122
serde = { version = "1.0", features = ["derive"] }
2223
serde_json = "1.0"
2324
tempfile = "3.0"
2425
walrus = { version = "0.23", features = ['parallel'] }
25-
regex = "1"
2626
wasm-bindgen-externref-xform = { path = '../externref-xform', version = '=0.2.100' }
2727
wasm-bindgen-multi-value-xform = { path = '../multi-value-xform', version = '=0.2.100' }
2828
wasm-bindgen-shared = { path = "../shared", version = '=0.2.100' }

crates/cli-support/src/js/binding.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1660,8 +1660,7 @@ impl Invocation {
16601660
if cx.import_never_log_error(import) {
16611661
*log_error = false;
16621662
}
1663-
let ret = cx.invoke_import(import, kind, args, variadic, prelude, import_deps);
1664-
return ret;
1663+
cx.invoke_import(import, kind, args, variadic, prelude, import_deps)
16651664
}
16661665
}
16671666
}

crates/cli-support/src/js/mod.rs

+18-22
Original file line numberDiff line numberDiff line change
@@ -987,11 +987,7 @@ __wbg_set_wasm(wasm);"
987987
}
988988

989989
let js = match &self.config.mode {
990-
OutputMode::Emscripten => format!(
991-
"\
992-
{imports_init}",
993-
imports_init = imports_init
994-
),
990+
OutputMode::Emscripten => imports_init.to_string(),
995991
_ => format!(
996992
"\
997993
async function __wbg_load(module, imports) {{
@@ -2654,15 +2650,15 @@ __wbg_set_wasm(wasm);"
26542650
}
26552651
let table = self.export_function_table()?;
26562652
if matches!(self.config.mode, OutputMode::Emscripten) {
2657-
self.emscripten_library.push_str(&format!(
2653+
self.emscripten_library.push_str(
26582654
"
26592655
$CLOSURE_DTORS: `(typeof FinalizationRegistry === 'undefined')
26602656
? {{ register: () => {{}}, unregister: () => {{}} }}
26612657
: new FinalizationRegistry(state => {{
26622658
wasmExports.__indirect_function_table.get(state.dtor)(state.a, state.b)
26632659
}})`,\n
2664-
"
2665-
));
2660+
",
2661+
);
26662662
} else {
26672663
self.global(&format!(
26682664
"
@@ -3187,20 +3183,20 @@ __wbg_set_wasm(wasm);"
31873183
"function() {{ return logError(function {}, arguments) }}",
31883184
code
31893185
)
3190-
} else {
3191-
if !import_deps.is_empty() {
3192-
for dep in &import_deps {
3193-
self.emscripten_deps.insert(dep.clone());
3194-
}
3195-
format!(
3196-
"function{},\n{}__deps: [{}]",
3197-
code,
3198-
self.module.imports.get(core).name,
3199-
import_deps.join(",")
3200-
)
3201-
} else {
3202-
format!("function{}\n", code)
3186+
} else if (matches!(self.config.mode, OutputMode::Emscripten)
3187+
&& !import_deps.is_empty())
3188+
{
3189+
for dep in &import_deps {
3190+
self.emscripten_deps.insert(dep.clone());
32033191
}
3192+
format!(
3193+
"function{},\n{}__deps: [{}]",
3194+
code,
3195+
self.module.imports.get(core).name,
3196+
import_deps.join(",")
3197+
)
3198+
} else {
3199+
format!("function{}\n", code)
32043200
};
32053201

32063202
self.wasm_import_definitions.insert(core, code);
@@ -3210,7 +3206,7 @@ __wbg_set_wasm(wasm);"
32103206
assert!(!log_error);
32113207

32123208
if matches!(self.config.mode, OutputMode::Emscripten) {
3213-
self.emscripten_library.push_str("$");
3209+
self.emscripten_library.push('$');
32143210
self.emscripten_library.push_str(&self.adapter_name(id));
32153211
self.emscripten_library.push_str(": function");
32163212
self.emscripten_library

crates/cli/src/bin/wasm-bindgen-test-runner/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn main() -> anyhow::Result<()> {
117117
.map(Path::new)
118118
.context("file to test is not a valid file, can't extract file name")?;
119119

120-
let mut file_name_buf = PathBuf::from(cli.file.clone());
120+
let mut file_name_buf = cli.file.clone();
121121

122122
// Repoint the file to be read from "name.js" to "name.wasm" in the case of emscripten.
123123
// Rustc generates a .js and a .wasm file when targeting emscripten. It lists the .js

crates/cli/src/bin/wasm-bindgen-test-runner/server.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ pub(crate) fn spawn(
353353
response
354354
})
355355
.map_err(|e| anyhow!("{}", e))?;
356-
return Ok(srv);
356+
Ok(srv)
357357
}
358358

359359
pub(crate) fn spawn_emscripten(
@@ -390,7 +390,7 @@ pub(crate) fn spawn_emscripten(
390390
response
391391
})
392392
.map_err(|e| anyhow!("{}", e))?;
393-
return Ok(srv);
393+
Ok(srv)
394394
}
395395

396396
fn try_asset(request: &Request, dir: &Path) -> Response {

src/convert/impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl WasmAbi for i128 {
4444

4545
#[inline]
4646
fn join(low: u64, high: u64, _: (), _: ()) -> Self {
47-
((high as u128) << 64 | low as u128) as i128
47+
(((high as u128) << 64) | low as u128) as i128
4848
}
4949
}
5050
impl WasmAbi for u128 {
@@ -62,7 +62,7 @@ impl WasmAbi for u128 {
6262

6363
#[inline]
6464
fn join(low: u64, high: u64, _: (), _: ()) -> Self {
65-
(high as u128) << 64 | low as u128
65+
((high as u128) << 64) | low as u128
6666
}
6767
}
6868

0 commit comments

Comments
 (0)