From 20acfb05f50312fe1d272d9d69d21d9bce4795ed Mon Sep 17 00:00:00 2001 From: Lucy Menon <168595099+syntactically@users.noreply.github.com> Date: Wed, 12 Aug 2026 20:07:43 +0100 Subject: [PATCH 1/2] [hyperlight_component_util] guest: avoid extra impls for Eq bounded vars Previously, the guest bindgen would emit an impl for a resource trait whenever it encountered an exported type _that resolved to_e a resource type. Unfortunately, this was incorrect: a tyvar that is bounded to be equal to a resource type should not generate a new impl of its own, since there is no trait for it. Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com> --- src/hyperlight_component_util/src/guest.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/hyperlight_component_util/src/guest.rs b/src/hyperlight_component_util/src/guest.rs index 18e555e3d3..b21d677c8f 100644 --- a/src/hyperlight_component_util/src/guest.rs +++ b/src/hyperlight_component_util/src/guest.rs @@ -18,9 +18,9 @@ use proc_macro2::TokenStream; use quote::{format_ident, quote}; use crate::emit::{ - FnName, ResolvedBoundVar, ResourceItemName, State, WitName, find_colliding_import_names, - import_member_names, kebab_to_exports_name, kebab_to_fn, kebab_to_getter, - kebab_to_imports_name, kebab_to_namespace, kebab_to_type, kebab_to_var, split_wit_name, + FnName, ResourceItemName, State, WitName, find_colliding_import_names, import_member_names, + kebab_to_exports_name, kebab_to_fn, kebab_to_getter, kebab_to_imports_name, kebab_to_namespace, + kebab_to_type, kebab_to_var, split_wit_name, }; use crate::etypes::{Component, Defined, ExternDecl, ExternDesc, Handleable, Instance, Tyvar}; use crate::hl::{ @@ -99,10 +99,11 @@ fn emit_import_extern_decl<'a, 'b, 'c>( ExternDesc::Type(t) => match t { Defined::Handleable(Handleable::Var(Tyvar::Bound(b))) => { // only resources need something emitted - let ResolvedBoundVar::Resource { rtidx } = s.resolve_bound_var(*b) else { + let noff = (s.var_offset as u32 + b) as usize; + let crate::etypes::TypeBound::SubResource = &s.bound_vars[noff].bound else { return quote! {}; }; - let rtid = format_ident!("HostResource{}", rtidx as usize); + let rtid = format_ident!("HostResource{}", noff); let path = s.resource_trait_path(kebab_to_type(ed.kebab_name)); s.root_mod .r#impl(path, format_ident!("Host")) From 2e72ca639b2b38498414fd3db19aa999943d7dfb Mon Sep 17 00:00:00 2001 From: Lucy Menon <168595099+syntactically@users.noreply.github.com> Date: Wed, 12 Aug 2026 20:13:43 +0100 Subject: [PATCH 2/2] [hyperlight_component_util] guest: correctly set export as `cur_trait` Previously, functions directly exported by a component, without an intervening instance, would not have had their bindings generated correctly: the bindings would have referred to a non-existent imported version of the function, since `State::cur_trait` was not set properly. Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com> --- src/hyperlight_component_util/src/guest.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hyperlight_component_util/src/guest.rs b/src/hyperlight_component_util/src/guest.rs index b21d677c8f..840db37c99 100644 --- a/src/hyperlight_component_util/src/guest.rs +++ b/src/hyperlight_component_util/src/guest.rs @@ -317,6 +317,7 @@ fn emit_component<'a, 'b, 'c>( s.var_offset = 0; s.is_export = true; + s.cur_trait = Some(export_trait.clone()); let exports = ct .instance