Skip to content
Open
Changes from all 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
9 changes: 7 additions & 2 deletions crates/wit-bindgen/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pub struct TypeInfo {

/// Whether or not this type (transitively) has a handle.
pub has_handle: bool,

/// Whether or not this type (transitively) has a future or a stream.
pub has_future_or_stream: bool,
}

impl std::ops::BitOrAssign for TypeInfo {
Expand All @@ -35,6 +38,7 @@ impl std::ops::BitOrAssign for TypeInfo {
self.error |= rhs.error;
self.has_list |= rhs.has_list;
self.has_handle |= rhs.has_handle;
self.has_future_or_stream |= rhs.has_future_or_stream;
}
}

Expand Down Expand Up @@ -153,6 +157,7 @@ impl Types {
}
TypeDefKind::Future(ty) | TypeDefKind::Stream(ty) => {
info = self.optional_type_info(resolve, ty.as_ref());
info.has_future_or_stream = true;
}
TypeDefKind::Handle(_) => info.has_handle = true,
TypeDefKind::Resource => {}
Expand Down Expand Up @@ -183,10 +188,10 @@ impl Types {

impl TypeInfo {
pub fn is_copy(&self) -> bool {
!self.has_list && !self.has_handle
!self.has_list && !self.has_handle && !self.has_future_or_stream
}

pub fn is_clone(&self) -> bool {
!self.has_handle
!self.has_handle && !self.has_future_or_stream
}
}