Skip to content

Emit mod.rs as the Rust receiver bindings root instead of lib.rs - #6593

Merged
Shubham8287 merged 1 commit into
clockworklabs:masterfrom
LucasWithK:LucasWithK/idc-rust-receiver-mod-rs
Nov 16, 2026
Merged

Shubham8287 merged 1 commit into
clockworklabs:masterfrom
LucasWithK:LucasWithK/idc-rust-receiver-mod-rs

Conversation

@LucasWithK

Copy link
Copy Markdown
Contributor

Description of Changes

Rust receiver (IDC) bindings generated with spacetime generate --bindings module --lang rust, without a dependencies entry in spacetime.json, writes its root file as lib.rs. A sender loads the bindings with mod remote_bindings;, which only finds remote_bindings.rs or remote_bindings/mod.rs, so the output could not be used without a manual #[path].

Only the spacetime.json dependency path renamed the root to {dependency}/mod.rs. The root is never a crate root: its outbox macros are pub(crate) and are called through the receiver module path by outbox! and #[table(outbox(...))], so they only resolve inside the sender crate.

  • Codegen now emits mod.rs as the root, matching Rust client bindings.
  • The CLI no longer special-cases lib.rs when placing dependency bindings.
  • The idc_receiver test fixture is renamed to mod.rs.

API and ABI breaking changes

No API or ABI changes. The generated file name changes from lib.rs to mod.rs for spacetime generate --bindings module without a spacetime.json dependency. Projects that load that output through #[path = ".../lib.rs"] need to update the path after regenerating. Bindings generated from spacetime.json dependencies are unchanged.

Rollback safety impact

n/a

Expected complexity level and risk

1

Testing

Updated:

  • Codegen tests and the receiver type declarations snapshot to expect the root file as mod.rs.
  • The bindings UI tests, module-test, and the codegen fixture comparison to load the renamed idc_receiver/mod.rs fixture.
  • The outbox shadowing test, which compiles generated receiver bindings as a submodule of a sender crate, to write the generated files as-is instead of renaming lib.rs to mod.rs.
  • The cli_generate_rust_module_bindings smoketest, which runs spacetime generate --bindings module without a spacetime.json dependency, to check that the output contains mod.rs and no lib.rs.

Existing smoketests generate bindings from spacetime.json dependencies, compile a sender that uses them, and deliver IDC calls between two Rust modules. They cover the dependency path, which still produces {dependency}/mod.rs.

I build the binary and tested it locally with my project that ran into that issue. It successfully generated a mod.rs file.

`spacetime generate --bindings module --lang rust` without a
spacetime.json dependency wrote the bindings root as lib.rs. A sender
loads the bindings with `mod remote_bindings;`, which only finds
remote_bindings.rs or remote_bindings/mod.rs, so the output could not
be used without a manual #[path]. Only the dependency path renamed
the file to mod.rs.

The root is never a crate root: its outbox macros are `pub(crate)`
and only resolve inside the sender crate. Codegen now emits mod.rs
directly, and the CLI no longer special-cases lib.rs.

Rename the idc_receiver test fixture to mod.rs and update the tests
and snapshots that expected lib.rs.
@CLAassistant

CLAassistant commented Nov 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@LucasWithK

Copy link
Copy Markdown
Contributor Author

Hey @Shubham8287, @joshua-spacetime this follows up on the Rust receiver bindings from #6375: without a spacetime.json dependency, generate --bindings module wrote the root as lib.rs, which a sender can't load as a module. Would one of you be able to take a look and approve the CI run? Thanks!

@Shubham8287 Shubham8287 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.

Thank you for fix!

@Shubham8287
Shubham8287 added this pull request to the merge queue Nov 16, 2026
Merged via the queue into clockworklabs:master with commit 98689d9 Nov 16, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants