Skip to content

fix: fully qualify Box::pin in ServiceGenerator#111

Merged
tillrohrmann merged 1 commit into
restatedev:mainfrom
MohamedBassem:fix/macro-hygine-box
May 11, 2026
Merged

fix: fully qualify Box::pin in ServiceGenerator#111
tillrohrmann merged 1 commit into
restatedev:mainfrom
MohamedBassem:fix/macro-hygine-box

Conversation

@MohamedBassem

Copy link
Copy Markdown
Contributor

Hello 👋

Was playing with a toy sandbox implementation baked by restate, and had a struct named Box (terrible name in the rust world, I know). This, however, uncovered an unqualified call to Box::pin in the service generator. So this tiny PR fixes that for better macro hygiene.

Repro

In the examples dir, add a struct named Box in any of the files:

diff --git a/examples/counter.rs b/examples/counter.rs
index 8f85bc8..61a761e 100644
--- a/examples/counter.rs
+++ b/examples/counter.rs
@@ -1,5 +1,7 @@
 use restate_sdk::prelude::*;

+pub struct Box {}
+
 #[restate_sdk::object]
 trait Counter {
     #[shared]

and the compiler will complain:

~/repos/restate-sdk-rust/examples ❯❯❯ cargo test                                                                                                                                                                                                                                                                                          fix/macro-hygine-box ✱
   Compiling restate-sdk v0.10.0 (/Users/mbassem/repos/restate-sdk-rust)
error[E0599]: no function or associated item named `pin` found for struct `Box` in the current scope
 --> examples/counter.rs:5:1
  |
3 | pub struct Box {}
  | -------------- function or associated item `pin` not found for this struct
4 |
5 | #[restate_sdk::object]
  | ^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `Box`
  |
  = note: this error originates in the attribute macro `restate_sdk::object` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0599`.
error: could not compile `restate-sdk` (example "counter") due to 1 previous error
warning: build failed, waiting for other jobs to finish...

After qualifying the call, it compiles and tests are passing.

@github-actions

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@MohamedBassem

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

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

Thanks a lot for creating this PR @MohamedBassem. LGTM. Merging this now :-)

@tillrohrmann tillrohrmann merged commit 1c1ba2c into restatedev:main May 11, 2026
3 of 4 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 11, 2026
@MohamedBassem MohamedBassem deleted the fix/macro-hygine-box branch May 11, 2026 18:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants