Skip to content

Commit 9872fef

Browse files
authored
Use TryClone::clone_panic_on_oom where it makes sense (#12681)
1 parent 0bc56e8 commit 9872fef

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

crates/environ/src/compile/module_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl ModuleTypesBuilder {
168168
// can reuse it in the future.
169169
TryCow::Borrowed(f) => {
170170
self.trampoline_types
171-
.insert(f.try_clone().panic_on_oom(), for_func_ty);
171+
.insert(f.clone_panic_on_oom(), for_func_ty);
172172
for_func_ty
173173
}
174174
// The trampoline type is different from the original function
@@ -179,7 +179,7 @@ impl ModuleTypesBuilder {
179179
is_final: true,
180180
supertype: None,
181181
composite_type: WasmCompositeType {
182-
inner: WasmCompositeInnerType::Func(f.try_clone().panic_on_oom()),
182+
inner: WasmCompositeInnerType::Func(f.clone_panic_on_oom()),
183183
shared: sub_ty.composite_type.shared,
184184
},
185185
});

crates/wasmtime/src/runtime/linker.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use core::future::Future;
1313
use core::marker;
1414
use core::mem::MaybeUninit;
1515
use log::warn;
16-
use wasmtime_environ::{Atom, PanicOnOom as _, StringPool, collections::HashMap};
16+
use wasmtime_environ::{Atom, StringPool, collections::HashMap};
1717

1818
/// Structure used to link wasm modules/instances together.
1919
///
@@ -100,8 +100,8 @@ impl<T> Clone for Linker<T> {
100100
fn clone(&self) -> Linker<T> {
101101
Linker {
102102
engine: self.engine.clone(),
103-
pool: self.pool.try_clone().panic_on_oom(),
104-
map: self.map.try_clone().panic_on_oom(),
103+
pool: self.pool.clone_panic_on_oom(),
104+
map: self.map.clone_panic_on_oom(),
105105
allow_shadowing: self.allow_shadowing,
106106
allow_unknown_exports: self.allow_unknown_exports,
107107
_marker: self._marker,

crates/wasmtime/src/runtime/type_registry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use core::{
2323
};
2424
use wasmtime_core::slab::{Id as SlabId, Slab};
2525
use wasmtime_environ::{
26-
EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes,
27-
PanicOnOom as _, TypeTrace, Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,
26+
EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes, TypeTrace,
27+
Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,
2828
collections::{HashSet, PrimaryMap, SecondaryMap, TryCow, Vec},
2929
iter_entity_range,
3030
packed_option::{PackedOption, ReservedValue},
@@ -272,7 +272,7 @@ impl Debug for RegisteredType {
272272

273273
impl Clone for RegisteredType {
274274
fn clone(&self) -> Self {
275-
self.try_clone().panic_on_oom()
275+
self.clone_panic_on_oom()
276276
}
277277
}
278278

crates/wasmtime/src/runtime/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ impl ExternType {
15091509
engine,
15101510
subty.is_final,
15111511
subty.supertype,
1512-
subty.unwrap_func().try_clone().panic_on_oom(),
1512+
subty.unwrap_func().clone_panic_on_oom(),
15131513
)
15141514
.panic_on_oom()
15151515
.into()

winch/codegen/src/codegen/control.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
stack::Val,
1717
};
1818
use cranelift_codegen::MachLabel;
19-
use wasmtime_environ::{PanicOnOom as _, WasmFuncType, WasmValType, collections::TryClone as _};
19+
use wasmtime_environ::{WasmFuncType, WasmValType, collections::TryClone as _};
2020

2121
/// Categorization of the type of the block.
2222
#[derive(Debug)]
@@ -37,7 +37,7 @@ impl Clone for BlockType {
3737
Self::Void => Self::Void,
3838
Self::Single(x) => Self::Single(*x),
3939
Self::ABISig(x) => Self::ABISig(x.clone()),
40-
Self::Func(f) => Self::Func(f.try_clone().panic_on_oom()),
40+
Self::Func(f) => Self::Func(f.clone_panic_on_oom()),
4141
}
4242
}
4343
}

winch/codegen/src/codegen/env.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ use std::mem;
1313
use wasmparser::BlockType;
1414
use wasmtime_environ::{
1515
BuiltinFunctionIndex, DefinedFuncIndex, FuncIndex, FuncKey, GlobalIndex, IndexType, Memory,
16-
MemoryIndex, ModuleTranslation, ModuleTypesBuilder, PanicOnOom as _, PrimaryMap, PtrSize,
17-
Table, TableIndex, TypeConvert, TypeIndex, VMOffsets, WasmHeapType, WasmValType,
18-
collections::TryClone as _,
16+
MemoryIndex, ModuleTranslation, ModuleTypesBuilder, PrimaryMap, PtrSize, Table, TableIndex,
17+
TypeConvert, TypeIndex, VMOffsets, WasmHeapType, WasmValType, collections::TryClone as _,
1918
};
2019

2120
#[derive(Debug, Clone, Copy)]
@@ -195,7 +194,7 @@ impl<'a, 'translation, 'data, P: PtrSize> FuncEnv<'a, 'translation, 'data, P> {
195194
let sig_index = self.translation.module.types[TypeIndex::from_u32(idx)]
196195
.unwrap_module_type_index();
197196
let sig = self.types[sig_index].unwrap_func();
198-
BlockSig::new(control::BlockType::func(sig.try_clone().panic_on_oom()))
197+
BlockSig::new(control::BlockType::func(sig.clone_panic_on_oom()))
199198
}
200199
})
201200
}

0 commit comments

Comments
 (0)