Skip to content

Commit 17923ff

Browse files
committed
refactor: use Linker::insert in Linker::resource
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent 1086ee2 commit 17923ff

1 file changed

Lines changed: 1 addition & 13 deletions

File tree

crates/wasmtime/src/component/linker.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -503,24 +503,12 @@ impl<T> LinkerInstance<'_, T> {
503503
&self.engine,
504504
move |mut cx: crate::Caller<'_, T>, param: u32| dtor(cx.as_context_mut(), param),
505505
));
506-
let entry = self.map.entry(name);
507-
if !self.allow_shadowing && matches!(entry, Entry::Occupied(_)) {
508-
bail!("import of `{}` defined twice", self.strings.strings[name])
509-
}
510506
let idx = ResourceImportIndex::new(*self.resource_imports);
511507
*self.resource_imports = self
512508
.resource_imports
513509
.checked_add(1)
514510
.context("resource import count would overflow")?;
515-
let def = Definition::Resource(idx, ty, dtor);
516-
match entry {
517-
Entry::Occupied(mut o) => {
518-
o.insert(def);
519-
}
520-
Entry::Vacant(v) => {
521-
v.insert(def);
522-
}
523-
}
511+
self.insert(name, Definition::Resource(idx, ty, dtor))?;
524512
Ok(idx)
525513
}
526514

0 commit comments

Comments
 (0)