| 1 |
#![cfg(feature = "wasmparser")] |
| 2 |
|
| 3 |
use arbitraryrust-analyzer cargo arbitrary 1.4.1 crate/::Unstructuredrust-analyzer cargo arbitrary 1.4.1 unstructured/Unstructured#; |
| •4 |
use randrust-analyzer cargo rand 0.10.1 crate/::{Rngrust-analyzer cargo rand_core 0.10.1 Rng#, SeedableRngrust-analyzer cargo rand_core 0.10.1 seedable_rng/SeedableRng#, rngsrust-analyzer cargo rand 0.10.1 rngs/::SmallRngrust-analyzer cargo rand 0.10.1 rngs/small/SmallRng#}; |
| 5 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#; |
| 6 |
use wasm_smithrust-analyzer cargo wasm-smith 0.239.0 crate/::{Configrust-analyzer cargo wasm-smith 0.239.0 config/Config#, Modulerust-analyzer cargo wasm-smith 0.239.0 core/Module#}; |
| 7 |
use wasmparserrust-analyzer cargo wasmparser 0.239.0 crate/::Validatorrust-analyzer cargo wasmparser 0.239.0 validator/Validator#; |
| 8 |
use wasmparserrust-analyzer cargo wasmparser 0.239.0 crate/::{Parserrust-analyzer cargo wasmparser 0.239.0 parser/Parser#, TypeRefrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#, ValTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#}; |
| 9 |
|
| 10 |
mod commonrust-analyzer cargo wasm-smith 0.239.0 common/; |
| 11 |
use commonrust-analyzer cargo wasm-smith 0.239.0 common/::validaterust-analyzer cargo wasm-smith 0.239.0 common/validate().; |
| 12 |
|
| 13 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 14 |
fn smoke_test_imports_configrust-analyzer cargo wasm-smith 0.239.0 smoke_test_imports_config().() { |
| 15 |
let mut n_partial = 0; |
| 16 |
let mut global_imports_seen = HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::<_, bool>::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(); |
| 17 |
let mut rng = SmallRngrust-analyzer cargo rand 0.10.1 rngs/small/SmallRng#::seed_from_u64rust-analyzer cargo rand 0.10.1 rngs/small/impl#[SmallRng][SeedableRng]seed_from_u64().(11); |
| 18 |
let mut buf = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; 512]; |
| 19 |
for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1024 { |
| 20 |
rng.fill_bytesrust-analyzer cargo rand_core 0.10.1 impl#[R][Rng]fill_bytes().(&mut buf); |
| 21 |
|
| 22 |
let mut u = Unstructuredrust-analyzer cargo arbitrary 1.4.1 unstructured/Unstructured#::newrust-analyzer cargo arbitrary 1.4.1 unstructured/impl#[`Unstructured<'a>`]new().(&buf); |
| 23 |
let (config, available) = import_configrust-analyzer cargo wasm-smith 0.239.0 import_config().(&mut u); |
| 24 |
let features = config.featuresrust-analyzer cargo wasm-smith 0.239.0 config/impl#[Config]features().(); |
| 25 |
|
| 26 |
if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(module) = Modulerust-analyzer cargo wasm-smith 0.239.0 core/Module#::newrust-analyzer cargo wasm-smith 0.239.0 core/impl#[Module]new().(config, &mut u) { |
| 27 |
let wasm_bytes = module.to_bytesrust-analyzer cargo wasm-smith 0.239.0 core/encode/impl#[Module]to_bytes().(); |
| 28 |
let mut validator = Validatorrust-analyzer cargo wasmparser 0.239.0 validator/Validator#::new_with_featuresrust-analyzer cargo wasmparser 0.239.0 validator/impl#[Validator]new_with_features().(features); |
| 29 |
validaterust-analyzer cargo wasm-smith 0.239.0 common/validate().(&mut validator, &wasm_bytes); |
| 30 |
let mut imports_seen = available |
| 31 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 32 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(m, f, t)| ((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().m, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().f), (false, t))) |
| 33 |
.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<_, _>>(); |
| 34 |
let mut sig_types = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 35 |
|
| 36 |
for payload in Parserrust-analyzer cargo wasmparser 0.239.0 parser/Parser#::newrust-analyzer cargo wasmparser 0.239.0 parser/impl#[Parser]new().(0).parse_allrust-analyzer cargo wasmparser 0.239.0 parser/impl#[Parser]parse_all().(&wasm_bytes) { |
| 37 |
let payload = payload.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 38 |
if let wasmparserrust-analyzer cargo wasmparser 0.239.0 crate/::Payloadrust-analyzer cargo wasmparser 0.239.0 parser/Payload#::TypeSectionrust-analyzer cargo wasmparser 0.239.0 parser/Payload#TypeSection#(rdr) = payload { |
| 39 |
// Gather the signature types to later check function types |
| 40 |
// against. |
| 41 |
for recgrp in rdr { |
| 42 |
let recgrp = recgrp.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 43 |
for subtype in recgrp.into_typesrust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[RecGroup]into_types().() { |
| 44 |
match subtype.composite_typerust-analyzer cargo wasmparser 0.239.0 readers/core/types/SubType#composite_type..innerrust-analyzer cargo wasmparser 0.239.0 readers/core/types/CompositeType#inner. { |
| 45 |
wasmparserrust-analyzer cargo wasmparser 0.239.0 crate/::CompositeInnerTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/CompositeInnerType#::Funcrust-analyzer cargo wasmparser 0.239.0 readers/core/types/CompositeInnerType#Func#(func_type) => { |
| 46 |
sig_types.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(func_type)) |
| 47 |
} |
| 48 |
_ => sig_types.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
} else if let wasmparserrust-analyzer cargo wasmparser 0.239.0 crate/::Payloadrust-analyzer cargo wasmparser 0.239.0 parser/Payload#::ImportSectionrust-analyzer cargo wasmparser 0.239.0 parser/Payload#ImportSection#(rdr) = payload { |
| 53 |
// Read out imports, checking that they all are within the |
| 54 |
// list of expected imports (i.e. we don't generate |
| 55 |
// arbitrary ones), and that we handle the logic correctly |
| 56 |
// (i.e. signature types are as expected) |
| 57 |
for import in rdr { |
| 58 |
let import = import.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 59 |
use AvailableImportKindrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind# as Irust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#; |
| 60 |
let entry = imports_seen.get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&(import.modulerust-analyzer cargo wasmparser 0.239.0 readers/core/imports/Import#module., import.namerust-analyzer cargo wasmparser 0.239.0 readers/core/imports/Import#name.)); |
| 61 |
match (entry, &import.tyrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/Import#ty.) { |
| 62 |
(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((true, _)), _) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("duplicate import of {import:?}"), |
| 63 |
(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((seen, Irust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#::Memoryrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Memory#)), TypeRefrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#::Memoryrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#Memory#(_)) => *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().seen = true, |
| 64 |
(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((seen, Irust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#::Globalrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Global#(t))), TypeRefrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#::Globalrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#Global#(gt)) |
| 65 |
if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t rust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[ValType][`PartialEq<Self>`]eq().==rust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[ValType][`PartialEq<Self>`]eq(). rust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[ValType][`PartialEq<Self>`]eq().gt.content_typerust-analyzer cargo wasmparser 0.239.0 readers/core/types/GlobalType#content_type. => |
| 66 |
{ |
| 67 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().seen = true |
| 68 |
} |
| 69 |
(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((seen, Irust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#::Tablerust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Table#(t))), TypeRefrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#::Tablerust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#Table#(tt)) |
| 70 |
if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t rust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[ValType][`PartialEq<Self>`]eq().==rust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[ValType][`PartialEq<Self>`]eq(). rust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[ValType][`PartialEq<Self>`]eq().ValTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#::Refrust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#Ref#(tt.element_typerust-analyzer cargo wasmparser 0.239.0 readers/core/types/TableType#element_type.) => |
| 71 |
{ |
| 72 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().seen = true |
| 73 |
} |
| 74 |
(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((seen, Irust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#::Funcrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Func#(p, r))), TypeRefrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#::Funcrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#Func#(sig_idx)) |
| 75 |
if sig_types[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().sig_idx as usize]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().paramsrust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[FuncType]params().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`&[T]`][`PartialEq<Vec<U, A>>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`&[T]`][`PartialEq<Vec<U, A>>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`&[T]`][`PartialEq<Vec<U, A>>`]eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().p |
| 76 |
&& sig_types[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().sig_idx as usize]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().resultsrust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[FuncType]results().() |
| 77 |
==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`&[T]`][`PartialEq<Vec<U, A>>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`&[T]`][`PartialEq<Vec<U, A>>`]eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().r => |
| 78 |
{ |
| 79 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().seen = true |
| 80 |
} |
| 81 |
( |
| 82 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((seen, Irust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#::Tagrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Tag#(p))), |
| 83 |
TypeRefrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#::Tagrust-analyzer cargo wasmparser 0.239.0 readers/core/imports/TypeRef#Tag#(wasmparserrust-analyzer cargo wasmparser 0.239.0 crate/::TagTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/TagType# { func_type_idxrust-analyzer cargo wasmparser 0.239.0 readers/core/types/TagType#func_type_idx., .. }), |
| 84 |
) if sig_types[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().func_type_idx as usize]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().paramsrust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[FuncType]params().() |
| 85 |
==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`&[T]`][`PartialEq<Vec<U, A>>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`&[T]`][`PartialEq<Vec<U, A>>`]eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().p |
| 86 |
&& sig_types[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().func_type_idx as usize]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). |
| 87 |
.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().() |
| 88 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 89 |
.resultsrust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[FuncType]results().() |
| 90 |
.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() => |
| 91 |
{ |
| 92 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().seen = true |
| 93 |
} |
| 94 |
(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((_, expected)), _) => { |
| 95 |
panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("import {import:?} type mismatch, expected: {expected:?}") |
| 96 |
} |
| 97 |
(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, _) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("import of an unknown entity: {import:?}"), |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
// Verify that we have seen both instances with partial imports |
| 104 |
// (i.e. we don't always just copy over all the imports from the |
| 105 |
// example module) and also that we eventually observe all of the |
| 106 |
// imports being used (i.e. selection is reasonably random) |
| 107 |
for (m, f, _) in &available[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 108 |
let seen = imports_seen[rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index().&(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().m, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().f)]rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index().; |
| 109 |
let global_seen = global_imports_seen |
| 110 |
.entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().((m.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), f.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())) |
| 111 |
.or_defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Entry<'a, K, V>`]or_default().(); |
| 112 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().global_seen rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitOrAssign<Self>`]bitor_assign().seen.0; |
| 113 |
} |
| 114 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().imports_seen.valuesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|v| v.0) { |
| 115 |
n_partial rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1; |
| 116 |
} |
| 117 |
} |
| 118 |
} |
| 119 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(global_imports_seen.valuesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|v| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().v)); |
| 120 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(n_partial >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt(). 0); |
| 121 |
} |
| 122 |
|
| 123 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 124 |
enum AvailableImportKindrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind# { |
| 125 |
Funcrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Func#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ValTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ValTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#>), |
| 126 |
Tagrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Tag#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ValTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#>), |
| 127 |
Globalrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Global#(ValTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#), |
| 128 |
Tablerust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Table#(ValTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#), |
| 129 |
Memoryrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Memory#, |
| 130 |
} |
| 131 |
|
| 132 |
fn import_configrust-analyzer cargo wasm-smith 0.239.0 import_config().( |
| 133 |
u: &mut Unstructuredrust-analyzer cargo arbitrary 1.4.1 unstructured/Unstructured#, |
| 134 |
) -> ( |
| 135 |
Configrust-analyzer cargo wasm-smith 0.239.0 config/Config#, |
| 136 |
Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(&'static str, &'static str, AvailableImportKindrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#)>, |
| 137 |
) { |
| 138 |
let mut config = Configrust-analyzer cargo wasm-smith 0.239.0 config/Config#::defaultrust-analyzer cargo wasm-smith 0.239.0 config/impl#[Config][Default]default().(); |
| 139 |
config.exceptions_enabledrust-analyzer cargo wasm-smith 0.239.0 config/Config#exceptions_enabled. = u.arbitraryrust-analyzer cargo arbitrary 1.4.1 unstructured/impl#[`Unstructured<'a>`]arbitrary().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("exceptions enabled for swarm"); |
| 140 |
let available = { |
| 141 |
use { |
| 142 |
AvailableImportKindrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#::*, |
| 143 |
ValTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#::*, |
| 144 |
wasmparserrust-analyzer cargo wasmparser 0.239.0 crate/::{PackedIndexrust-analyzer cargo wasmparser 0.239.0 readers/core/types/PackedIndex#, RefTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/RefType#}, |
| 145 |
}; |
| 146 |
vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 147 |
("env", "pi", Funcrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Func#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![])), |
| 148 |
("env", "pi2", Funcrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Func#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![])), |
| 149 |
("env", "pipi2", Funcrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Func#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#, I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![])), |
| 150 |
("env", "po", Funcrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Func#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#])), |
| 151 |
("env", "pipo", Funcrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Func#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#])), |
| 152 |
("env", "popo", Funcrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Func#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#, I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#])), |
| 153 |
("env", "mem", Memoryrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Memory#), |
| 154 |
("env", "tbl", Tablerust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Table#(ValTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#::FUNCREFrust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[ValType]FUNCREF.)), |
| 155 |
("vars", "g", Globalrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Global#(I64rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I64#)), |
| 156 |
("tags", "tag1", Tagrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Tag#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![I32rust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#I32#])), |
| 157 |
( |
| 158 |
"tags", |
| 159 |
"tag2", |
| 160 |
Tagrust-analyzer cargo wasm-smith 0.239.0 AvailableImportKind#Tag#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Refrust-analyzer cargo wasmparser 0.239.0 readers/core/types/ValType#Ref#(RefTyperust-analyzer cargo wasmparser 0.239.0 readers/core/types/RefType#::concreterust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[RefType]concrete().( |
| 161 |
true, |
| 162 |
PackedIndexrust-analyzer cargo wasmparser 0.239.0 readers/core/types/PackedIndex#::from_module_indexrust-analyzer cargo wasmparser 0.239.0 readers/core/types/impl#[PackedIndex]from_module_index().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 163 |
))]), |
| 164 |
), |
| 165 |
] |
| 166 |
}; |
| 167 |
config.available_importsrust-analyzer cargo wasm-smith 0.239.0 config/Config#available_imports. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( |
| 168 |
watrust-analyzer cargo wat 1.239.0 crate/::parse_strrust-analyzer cargo wat 1.239.0 parse_str().( |
| 169 |
r#" |
| 170 |
(module |
| 171 |
(rec |
| 172 |
(type $s0 (array (ref $s1))) |
| 173 |
(type $s1 (array (ref $s0))) |
| 174 |
) |
| 175 |
(import "env" "pi" (func (param i32))) |
| 176 |
(import "env" "pi2" (func (param i32))) |
| 177 |
(import "env" "pipi2" (func (param i32 i32))) |
| 178 |
(import "env" "po" (func (result i32))) |
| 179 |
(import "env" "pipo" (func (param i32) (result i32))) |
| 180 |
(import "env" "popo" (func (result i32 i32))) |
| 181 |
(import "env" "mem" (memory 1 16)) |
| 182 |
(import "env" "tbl" (table 1 16 funcref)) |
| 183 |
(import "vars" "g" (global i64)) |
| 184 |
(import "tags" "tag1" (tag (param i32))) |
| 185 |
(import "tags" "tag2" (tag (param (ref null $s0)))) |
| 186 |
) |
| 187 |
"#, |
| 188 |
) |
| 189 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 190 |
.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 191 |
); |
| 192 |
(config, available) |
| 193 |
} |