Skip to content

Commit 1ca54f2

Browse files
authored
Fix two cases of non-deterministic iteration (#2304)
* Fix two cases of non-deterministic iteration This commit fixes an issue of nondeterministic JS generation when closures were used, updating a few iterations of hash maps to iterate in a sorted manner rather than via the raw internal order. Closes #2302 * Reformat web-sys with latest proc-macro
1 parent c34606e commit 1ca54f2

File tree

1,140 files changed

+9059
-9056
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,140 files changed

+9059
-9056
lines changed

crates/cli-support/src/descriptors.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ impl WasmBindgenDescriptorsSection {
116116
// freshly manufactured import. Save off the type of this import in
117117
// ourselves, and then we're good to go.
118118
let ty = module.funcs.get(wbindgen_describe_closure).ty();
119-
for (func, descriptor) in func_to_descriptor {
119+
// sort to ensure ids and caches are consistent across runs
120+
let mut items = func_to_descriptor.into_iter().collect::<Vec<_>>();
121+
items.sort_by_key(|i| i.0);
122+
for (func, descriptor) in items {
120123
// This uses a cache so that if the same closure exists multiple times it will
121124
// deduplicate it so it only exists once.
122125
let id = match self.cached_closures.get(&descriptor) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ impl<'a> Context<'a> {
183183
// Finally we store all this metadata in the import map which we've
184184
// learned so when a binding for the import is generated we can
185185
// generate all the appropriate shims.
186-
for (id, descriptor) in closure_imports {
186+
for (id, descriptor) in crate::sorted_iter(&closure_imports) {
187187
let signature = Function {
188188
shim_idx: 0,
189189
arguments: vec![Descriptor::I32; 3],
190190
ret: Descriptor::Externref,
191191
};
192-
let id = self.import_adapter(id, signature, AdapterJsImportKind::Normal)?;
192+
let id = self.import_adapter(*id, signature, AdapterJsImportKind::Normal)?;
193193
// Synthesize the two integer pointers we pass through which
194194
// aren't present in the signature but are present in the wasm
195195
// signature.

crates/web-sys/src/features/gen_AbortController.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use wasm_bindgen::prelude::*;
44
#[wasm_bindgen]
55
extern "C" {
6-
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = AbortController , typescript_type = "AbortController" ) ]
6+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AbortController , typescript_type = "AbortController")]
77
#[derive(Debug, Clone, PartialEq, Eq)]
88
#[doc = "The `AbortController` class."]
99
#[doc = ""]
@@ -12,7 +12,7 @@ extern "C" {
1212
#[doc = "*This API requires the following crate features to be activated: `AbortController`*"]
1313
pub type AbortController;
1414
#[cfg(feature = "AbortSignal")]
15-
# [ wasm_bindgen ( structural , method , getter , js_class = "AbortController" , js_name = signal ) ]
15+
# [wasm_bindgen (structural , method , getter , js_class = "AbortController" , js_name = signal)]
1616
#[doc = "Getter for the `signal` field of this object."]
1717
#[doc = ""]
1818
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal)"]
@@ -26,7 +26,7 @@ extern "C" {
2626
#[doc = ""]
2727
#[doc = "*This API requires the following crate features to be activated: `AbortController`*"]
2828
pub fn new() -> Result<AbortController, JsValue>;
29-
# [ wasm_bindgen ( method , structural , js_class = "AbortController" , js_name = abort ) ]
29+
# [wasm_bindgen (method , structural , js_class = "AbortController" , js_name = abort)]
3030
#[doc = "The `abort()` method."]
3131
#[doc = ""]
3232
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort)"]

crates/web-sys/src/features/gen_AbortSignal.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ use super::*;
33
use wasm_bindgen::prelude::*;
44
#[wasm_bindgen]
55
extern "C" {
6-
# [ wasm_bindgen ( extends = EventTarget , extends = :: js_sys :: Object , js_name = AbortSignal , typescript_type = "AbortSignal" ) ]
6+
# [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = AbortSignal , typescript_type = "AbortSignal")]
77
#[derive(Debug, Clone, PartialEq, Eq)]
88
#[doc = "The `AbortSignal` class."]
99
#[doc = ""]
1010
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)"]
1111
#[doc = ""]
1212
#[doc = "*This API requires the following crate features to be activated: `AbortSignal`*"]
1313
pub type AbortSignal;
14-
# [ wasm_bindgen ( structural , method , getter , js_class = "AbortSignal" , js_name = aborted ) ]
14+
# [wasm_bindgen (structural , method , getter , js_class = "AbortSignal" , js_name = aborted)]
1515
#[doc = "Getter for the `aborted` field of this object."]
1616
#[doc = ""]
1717
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/aborted)"]
1818
#[doc = ""]
1919
#[doc = "*This API requires the following crate features to be activated: `AbortSignal`*"]
2020
pub fn aborted(this: &AbortSignal) -> bool;
21-
# [ wasm_bindgen ( structural , method , getter , js_class = "AbortSignal" , js_name = onabort ) ]
21+
# [wasm_bindgen (structural , method , getter , js_class = "AbortSignal" , js_name = onabort)]
2222
#[doc = "Getter for the `onabort` field of this object."]
2323
#[doc = ""]
2424
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/onabort)"]
2525
#[doc = ""]
2626
#[doc = "*This API requires the following crate features to be activated: `AbortSignal`*"]
2727
pub fn onabort(this: &AbortSignal) -> Option<::js_sys::Function>;
28-
# [ wasm_bindgen ( structural , method , setter , js_class = "AbortSignal" , js_name = onabort ) ]
28+
# [wasm_bindgen (structural , method , setter , js_class = "AbortSignal" , js_name = onabort)]
2929
#[doc = "Setter for the `onabort` field of this object."]
3030
#[doc = ""]
3131
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/onabort)"]

crates/web-sys/src/features/gen_AddEventListenerOptions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use wasm_bindgen::prelude::*;
44
#[wasm_bindgen]
55
extern "C" {
6-
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = AddEventListenerOptions ) ]
6+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AddEventListenerOptions)]
77
#[derive(Debug, Clone, PartialEq, Eq)]
88
#[doc = "The `AddEventListenerOptions` dictionary."]
99
#[doc = ""]

crates/web-sys/src/features/gen_AesCbcParams.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use wasm_bindgen::prelude::*;
44
#[wasm_bindgen]
55
extern "C" {
6-
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = AesCbcParams ) ]
6+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AesCbcParams)]
77
#[derive(Debug, Clone, PartialEq, Eq)]
88
#[doc = "The `AesCbcParams` dictionary."]
99
#[doc = ""]

crates/web-sys/src/features/gen_AesCtrParams.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use wasm_bindgen::prelude::*;
44
#[wasm_bindgen]
55
extern "C" {
6-
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = AesCtrParams ) ]
6+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AesCtrParams)]
77
#[derive(Debug, Clone, PartialEq, Eq)]
88
#[doc = "The `AesCtrParams` dictionary."]
99
#[doc = ""]

crates/web-sys/src/features/gen_AesDerivedKeyParams.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use wasm_bindgen::prelude::*;
44
#[wasm_bindgen]
55
extern "C" {
6-
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = AesDerivedKeyParams ) ]
6+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AesDerivedKeyParams)]
77
#[derive(Debug, Clone, PartialEq, Eq)]
88
#[doc = "The `AesDerivedKeyParams` dictionary."]
99
#[doc = ""]

crates/web-sys/src/features/gen_AesGcmParams.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use wasm_bindgen::prelude::*;
44
#[wasm_bindgen]
55
extern "C" {
6-
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = AesGcmParams ) ]
6+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AesGcmParams)]
77
#[derive(Debug, Clone, PartialEq, Eq)]
88
#[doc = "The `AesGcmParams` dictionary."]
99
#[doc = ""]

crates/web-sys/src/features/gen_AesKeyAlgorithm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use wasm_bindgen::prelude::*;
44
#[wasm_bindgen]
55
extern "C" {
6-
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = AesKeyAlgorithm ) ]
6+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AesKeyAlgorithm)]
77
#[derive(Debug, Clone, PartialEq, Eq)]
88
#[doc = "The `AesKeyAlgorithm` dictionary."]
99
#[doc = ""]

0 commit comments

Comments
 (0)