Skip to content

[hyperlight_component_util] Properly disambiguate chains of associated types - #1721

Merged
syntactically merged 1 commit into
mainfrom
lm/component-disambiguate-chains
Aug 13, 2026
Merged

syntactically merged 1 commit into
mainfrom
lm/component-disambiguate-chains

Conversation

@syntactically

Copy link
Copy Markdown
Member

Previously, the Rust component bindgen would in certain circumstances produce long chains of associated type references, e.g. Self::Foo::Bar::Baz::T. Unfortunately, Rust will not actually accept these without disambiguating syntax indicating from which trait the extern types should be drawn. This commit modifies the relevant logic in emit_resource_ref to walk through the path properly, and then deals with the consequences of that everywhere else.

@syntactically
syntactically requested a review from danbugs as a code owner August 12, 2026 10:22
Copilot AI lite review requested due to automatic review settings August 12, 2026 10:22
@syntactically syntactically added the C-bug For PRs that fix bugs label Aug 12, 2026
@syntactically
syntactically force-pushed the lm/component-disambiguate-chains branch from b80535f to 7977dbe Compare August 12, 2026 10:25
@syntactically
syntactically force-pushed the lm/component-disambiguate-chains branch from 7977dbe to b993b38 Compare August 12, 2026 10:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Rust component bindgen codegen so chains of associated types (for nested instance/resource references) are emitted with the necessary trait disambiguation syntax, avoiding invalid paths like Self::Foo::Bar::Baz::T in cases where Rust requires qualified syntax.

Changes:

  • Reworked emit_resource_ref to walk the path step-by-step and introduce trait_ref for consistent trait-path emission with instantiated type variables.
  • Updated host/guest impl codegen state-path handling to carry trait bounds for nested associated-type projections, and generalized self_param_var to a TokenStream.
  • Added a regression coverage module that exercises deeply nested instance/resource paths.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/hyperlight_host/tests/wit_test.rs Adds a deeply-nested inline component to exercise the problematic associated-type path pattern in host bindgen.
src/hyperlight_component_util/src/rtypes.rs Implements trait-disambiguated resource-type reference emission and adds trait_ref helper.
src/hyperlight_component_util/src/host.rs Tracks nested state projections with explicit trait bounds to generate disambiguated associated-type paths in host impl codegen.
src/hyperlight_component_util/src/guest.rs Aligns guest impl codegen self_param_var handling with the new TokenStream representation and export-trait qualification.
src/hyperlight_component_util/src/emit.rs Updates State::self_param_var to Option<TokenStream> and documents origin/self-parameter expectations for higher-order components.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/hyperlight_host/tests/wit_test.rs Resolved
jsturtevant
jsturtevant previously approved these changes Aug 12, 2026
@syntactically
syntactically force-pushed the lm/component-disambiguate-chains branch 3 times, most recently from 17cbd9e to c3448c5 Compare August 12, 2026 19:48
@syntactically
syntactically changed the base branch from lm/component-test-qol to lm/component-guest-fixes August 12, 2026 19:54
@syntactically
syntactically force-pushed the lm/component-disambiguate-chains branch from c3448c5 to 0ec1b0f Compare August 13, 2026 08:58
…d types

Previously, the Rust component bindgen would in certain circumstances
produce long chains of associated type references,
e.g. Self::Foo::Bar::Baz::T. Unfortunately, Rust will not actually
accept these without disambiguating syntax indicating from which trait
the extern types should be drawn. This commit modifies the relevant
logic in `emit_resource_ref` to walk through the path properly, and
then deals with the consequences of that everywhere else.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
@syntactically
syntactically force-pushed the lm/component-disambiguate-chains branch from 0ec1b0f to 6cb3adf Compare August 13, 2026 10:47
@syntactically syntactically added the S-needs-review PR is ready for (re-)review label Aug 13, 2026
Base automatically changed from lm/component-guest-fixes to main August 13, 2026 17:47
@syntactically
syntactically merged commit 6cb3adf into main Aug 13, 2026
59 of 64 checks passed
@syntactically
syntactically deleted the lm/component-disambiguate-chains branch August 13, 2026 21:26
@github-actions github-actions Bot removed the S-needs-review PR is ready for (re-)review label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bug For PRs that fix bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants