Skip to content

Fix #[import] macro: drop trailing unit to avoid clippy::unused_unit in user code#17

Merged
colinrozzi merged 1 commit into
mainfrom
fix-macro-unused-unit
May 9, 2026
Merged

Fix #[import] macro: drop trailing unit to avoid clippy::unused_unit in user code#17
colinrozzi merged 1 commit into
mainfrom
fix-macro-unused-unit

Conversation

@colinrozzi
Copy link
Copy Markdown
Owner

When an imported function has no return type (e.g. log: func(msg: string)), the macro previously emitted:

fn log(msg: String) -> () {
    let input = ...;
    let result = packr_guest::__import_impl(...);
    ()  // <-- unused unit
}

Both -> () and the trailing () trigger clippy::unused_unit from inside an attribute macro. Users running cargo clippy -- -D warnings (typical CI setup) get errors they can't fix without an #[allow] workaround.

Now we emit nothing for the return clause and drop the result statement when there's no return type. Same fix in both #[import] (module attr) and #[import_from] (package attr).

Verified against hello-actor: clippy is clean with this change, no #[allow(clippy::unused_unit)] needed.

@colinrozzi colinrozzi enabled auto-merge (squash) May 9, 2026 15:26
@colinrozzi colinrozzi merged commit 666394a into main May 9, 2026
2 checks passed
@colinrozzi colinrozzi mentioned this pull request May 9, 2026
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.

1 participant