Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 23 additions & 23 deletions crates/component-macro/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ fn expand_record_for_component_type(
fn typecheck(
ty: &#internal::InterfaceType,
types: &#internal::InstanceType<'_>,
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
#internal::#typecheck(ty, types, &[#typecheck_argument])
}
}
Expand Down Expand Up @@ -489,7 +489,7 @@ impl Expander for LiftExpander {
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
src: &Self::Lower,
) -> #internal::anyhow::Result<Self> {
) -> #wt::Result<Self> {
#extract_ty
Ok(Self {
#lifts
Expand All @@ -501,7 +501,7 @@ impl Expander for LiftExpander {
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
bytes: &[u8],
) -> #internal::anyhow::Result<Self> {
) -> #wt::Result<Self> {
#extract_ty
debug_assert!(
(bytes.as_ptr() as usize)
Expand Down Expand Up @@ -580,11 +580,11 @@ impl Expander for LiftExpander {
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
src: &Self::Lower,
) -> #internal::anyhow::Result<Self> {
) -> #wt::Result<Self> {
#extract_ty
Ok(match src.tag.get_u32() {
#lifts
discrim => #internal::anyhow::bail!("unexpected discriminant: {}", discrim),
discrim => #wt::bail!("unexpected discriminant: {}", discrim),
})
}

Expand All @@ -593,7 +593,7 @@ impl Expander for LiftExpander {
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
bytes: &[u8],
) -> #internal::anyhow::Result<Self> {
) -> #wt::Result<Self> {
let align = <Self as #wt::component::ComponentType>::ALIGN32;
debug_assert!((bytes.as_ptr() as usize) % (align as usize) == 0);
let discrim = #from_bytes;
Expand All @@ -602,7 +602,7 @@ impl Expander for LiftExpander {
#extract_ty
Ok(match discrim {
#loads
discrim => #internal::anyhow::bail!("unexpected discriminant: {}", discrim),
discrim => #wt::bail!("unexpected discriminant: {}", discrim),
})
}
}
Expand Down Expand Up @@ -647,11 +647,11 @@ impl Expander for LiftExpander {
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
src: &Self::Lower,
) -> #internal::anyhow::Result<Self> {
) -> #wt::Result<Self> {
#extract_ty
let discrim = src.tag.get_u32();
if discrim >= #discrim_limit {
#internal::anyhow::bail!("unexpected discriminant: {discrim}");
#wt::bail!("unexpected discriminant: {discrim}");
}
Ok(unsafe {
#internal::transmute::<#discrim_ty, #name>(discrim as #discrim_ty)
Expand All @@ -663,12 +663,12 @@ impl Expander for LiftExpander {
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
bytes: &[u8],
) -> #internal::anyhow::Result<Self> {
) -> #wt::Result<Self> {
let align = <Self as #wt::component::ComponentType>::ALIGN32;
debug_assert!((bytes.as_ptr() as usize) % (align as usize) == 0);
let discrim = #from_bytes;
if u32::from(discrim) >= #discrim_limit {
#internal::anyhow::bail!("unexpected discriminant: {discrim}");
#wt::bail!("unexpected discriminant: {discrim}");
}
Ok(unsafe {
#internal::transmute::<#discrim_ty, #name>(discrim)
Expand Down Expand Up @@ -728,7 +728,7 @@ impl Expander for LowerExpander {
cx: &mut #internal::LowerContext<'_, T>,
ty: #internal::InterfaceType,
dst: &mut core::mem::MaybeUninit<Self::Lower>,
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
#extract_ty
#lowers
Ok(())
Expand All @@ -740,7 +740,7 @@ impl Expander for LowerExpander {
cx: &mut #internal::LowerContext<'_, T>,
ty: #internal::InterfaceType,
mut offset: usize
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
debug_assert!(offset % (<Self as #wt::component::ComponentType>::ALIGN32 as usize) == 0);
#extract_ty
#stores
Expand Down Expand Up @@ -826,7 +826,7 @@ impl Expander for LowerExpander {
cx: &mut #internal::LowerContext<'_, T>,
ty: #internal::InterfaceType,
dst: &mut core::mem::MaybeUninit<Self::Lower>,
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
#extract_ty
match self {
#lowers
Expand All @@ -839,7 +839,7 @@ impl Expander for LowerExpander {
cx: &mut #internal::LowerContext<'_, T>,
ty: #internal::InterfaceType,
mut offset: usize
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
#extract_ty
debug_assert!(offset % (<Self as #wt::component::ComponentType>::ALIGN32 as usize) == 0);
match self {
Expand Down Expand Up @@ -883,7 +883,7 @@ impl Expander for LowerExpander {
cx: &mut #internal::LowerContext<'_, T>,
ty: #internal::InterfaceType,
dst: &mut core::mem::MaybeUninit<Self::Lower>,
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
#extract_ty
#internal::map_maybe_uninit!(dst.tag)
.write(#wt::ValRaw::u32(*self as u32));
Expand All @@ -896,7 +896,7 @@ impl Expander for LowerExpander {
cx: &mut #internal::LowerContext<'_, T>,
ty: #internal::InterfaceType,
mut offset: usize
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
#extract_ty
debug_assert!(offset % (<Self as #wt::component::ComponentType>::ALIGN32 as usize) == 0);
let discrim = *self as #ty;
Expand Down Expand Up @@ -1026,7 +1026,7 @@ impl Expander for ComponentTypeExpander {
fn typecheck(
ty: &#internal::InterfaceType,
types: &#internal::InstanceType<'_>,
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
#internal::typecheck_variant(ty, types, &[#case_names_and_checks])
}

Expand Down Expand Up @@ -1087,7 +1087,7 @@ impl Expander for ComponentTypeExpander {
fn typecheck(
ty: &#internal::InterfaceType,
types: &#internal::InstanceType<'_>,
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
#internal::typecheck_enum(ty, types, &[#case_names])
}

Expand Down Expand Up @@ -1472,7 +1472,7 @@ pub fn expand_flags(flags: &Flags) -> Result<TokenStream> {
cx: &mut #internal::LowerContext<'_, T>,
_ty: #internal::InterfaceType,
dst: &mut core::mem::MaybeUninit<Self::Lower>,
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
#(
self.#field_names.linear_lower_to_flat(
cx,
Expand All @@ -1488,7 +1488,7 @@ pub fn expand_flags(flags: &Flags) -> Result<TokenStream> {
cx: &mut #internal::LowerContext<'_, T>,
_ty: #internal::InterfaceType,
mut offset: usize
) -> #internal::anyhow::Result<()> {
) -> #wt::Result<()> {
debug_assert!(offset % (<Self as #wt::component::ComponentType>::ALIGN32 as usize) == 0);
#(
self.#field_names.linear_lower_to_memory(
Expand All @@ -1507,7 +1507,7 @@ pub fn expand_flags(flags: &Flags) -> Result<TokenStream> {
cx: &mut #internal::LiftContext<'_>,
_ty: #internal::InterfaceType,
src: &Self::Lower,
) -> #internal::anyhow::Result<Self> {
) -> #wt::Result<Self> {
Ok(Self {
#(
#field_names: #wt::component::Lift::linear_lift_from_flat(
Expand All @@ -1523,7 +1523,7 @@ pub fn expand_flags(flags: &Flags) -> Result<TokenStream> {
cx: &mut #internal::LiftContext<'_>,
_ty: #internal::InterfaceType,
bytes: &[u8],
) -> #internal::anyhow::Result<Self> {
) -> #wt::Result<Self> {
debug_assert!(
(bytes.as_ptr() as usize)
% (<Self as #wt::component::ComponentType>::ALIGN32 as usize)
Expand Down
2 changes: 1 addition & 1 deletion crates/component-macro/tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ macro_rules! gentest {
component_macro_test_helpers::foreach!(gentest);

mod with_key_and_resources {
use anyhow::Result;
use wasmtime::Result;
use wasmtime::component::Resource;

wasmtime::component::bindgen!({
Expand Down
2 changes: 1 addition & 1 deletion crates/component-macro/tests/expanded.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::Path;

use anyhow::{Context, Result, bail};
use wasmtime::{Result, bail, error::Context};

macro_rules! genexpand {
($id:ident $name:tt $path:tt) => {
Expand Down
10 changes: 4 additions & 6 deletions crates/component-macro/tests/expanded/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ pub struct TheWorld {
interface0: exports::foo::foo::chars::Guest,
}
const _: () = {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
impl TheWorldIndices {
/// Creates a new copy of `TheWorldIndices` bindings which can then
/// be used to instantiate into a particular store.
Expand Down Expand Up @@ -190,7 +188,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::{anyhow, Box};
use wasmtime::component::__internal::Box;
pub trait HostWithStore: wasmtime::component::HasData {}
impl<_T: ?Sized> HostWithStore for _T
where
Expand Down Expand Up @@ -252,7 +250,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::{anyhow, Box};
use wasmtime::component::__internal::Box;
#[derive(Clone)]
pub struct Guest {
take_char: wasmtime::component::Func,
Expand All @@ -277,7 +275,7 @@ pub mod exports {
.component()
.get_export_index(None, "foo:foo/chars")
.ok_or_else(|| {
anyhow::anyhow!(
wasmtime::format_err!(
"no exported instance named `foo:foo/chars`"
)
})?;
Expand All @@ -286,7 +284,7 @@ pub mod exports {
.component()
.get_export_index(Some(&instance), name)
.ok_or_else(|| {
anyhow::anyhow!(
wasmtime::format_err!(
"instance export `foo:foo/chars` does \
not have export `{name}`"
)
Expand Down
10 changes: 4 additions & 6 deletions crates/component-macro/tests/expanded/char_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ pub struct TheWorld {
interface0: exports::foo::foo::chars::Guest,
}
const _: () = {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
impl TheWorldIndices {
/// Creates a new copy of `TheWorldIndices` bindings which can then
/// be used to instantiate into a particular store.
Expand Down Expand Up @@ -190,7 +188,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::{anyhow, Box};
use wasmtime::component::__internal::Box;
pub trait HostWithStore: wasmtime::component::HasData + Send {}
impl<_T: ?Sized> HostWithStore for _T
where
Expand Down Expand Up @@ -266,7 +264,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::{anyhow, Box};
use wasmtime::component::__internal::Box;
#[derive(Clone)]
pub struct Guest {
take_char: wasmtime::component::Func,
Expand All @@ -291,7 +289,7 @@ pub mod exports {
.component()
.get_export_index(None, "foo:foo/chars")
.ok_or_else(|| {
anyhow::anyhow!(
wasmtime::format_err!(
"no exported instance named `foo:foo/chars`"
)
})?;
Expand All @@ -300,7 +298,7 @@ pub mod exports {
.component()
.get_export_index(Some(&instance), name)
.ok_or_else(|| {
anyhow::anyhow!(
wasmtime::format_err!(
"instance export `foo:foo/chars` does \
not have export `{name}`"
)
Expand Down
10 changes: 4 additions & 6 deletions crates/component-macro/tests/expanded/char_concurrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ pub struct TheWorld {
interface0: exports::foo::foo::chars::Guest,
}
const _: () = {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
impl TheWorldIndices {
/// Creates a new copy of `TheWorldIndices` bindings which can then
/// be used to instantiate into a particular store.
Expand Down Expand Up @@ -190,7 +188,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::{anyhow, Box};
use wasmtime::component::__internal::Box;
pub trait HostWithStore: wasmtime::component::HasData + Send {
/// A function that accepts a character
fn take_char<T>(
Expand Down Expand Up @@ -245,7 +243,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::{anyhow, Box};
use wasmtime::component::__internal::Box;
#[derive(Clone)]
pub struct Guest {
take_char: wasmtime::component::Func,
Expand All @@ -270,7 +268,7 @@ pub mod exports {
.component()
.get_export_index(None, "foo:foo/chars")
.ok_or_else(|| {
anyhow::anyhow!(
wasmtime::format_err!(
"no exported instance named `foo:foo/chars`"
)
})?;
Expand All @@ -279,7 +277,7 @@ pub mod exports {
.component()
.get_export_index(Some(&instance), name)
.ok_or_else(|| {
anyhow::anyhow!(
wasmtime::format_err!(
"instance export `foo:foo/chars` does \
not have export `{name}`"
)
Expand Down
Loading