Skip to content

fix: use ready futures for synchronous trait handlers - #111

Open
lucarlig wants to merge 1 commit into
mainfrom
user/luca/fix-unused-async-handlers
Open

fix: use ready futures for synchronous trait handlers#111
lucarlig wants to merge 1 commit into
mainfrom
user/luca/fix-unused-async-handlers

Conversation

@lucarlig

@lucarlig lucarlig commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace nine no-await async trait implementations with std::future::Ready
  • keep clippy::unused_async_trait_impl enabled through the workspace pedantic lint group

This is the bottom PR beneath #107 and #109.

Why

Clippy's unused_async_trait_impl documentation recommends returning std::future::ready when an async trait implementation contains no .await. This avoids generating an async state machine for work that is entirely synchronous.

The change covers all nine affected functions: one production plugin handler and eight test or mock handlers. Their results are computed when the method is called and returned through Ready; no lint suppression remains.

Verification

  • Rust 1.98 workspace Clippy with all targets, all features, and warnings denied
  • Rust 1.96.1 workspace Clippy with all targets, all features, and warnings denied
  • workspace nextest: 224 passed, 5 skipped
  • repository commit hooks

@lucarlig
lucarlig marked this pull request as ready for review August 21, 2026 16:47
@lucarlig lucarlig changed the title fix: avoid unused async trait handlers chore: allow unused async trait handlers Aug 24, 2026
@lucarlig
lucarlig requested a review from dawid-nowak August 24, 2026 09:27
@lucarlig lucarlig changed the title chore: allow unused async trait handlers fix: use ready futures for synchronous trait handlers Aug 24, 2026
Signed-off-by: lucarlig <luca.carlig@ibm.com>
@lucarlig
lucarlig force-pushed the user/luca/fix-unused-async-handlers branch from 4ab6dc6 to 655bffb Compare August 24, 2026 14:29

@dawid-nowak dawid-nowak 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.

Why are we returning a future if the interface is not async?
Or what am I missing?

_ctx: &mut PluginContext,
) -> PluginResult<MessagePayload> {
) -> impl std::future::Future<Output = PluginResult<MessagePayload>> {
let scan = self.scan_payload(payload);

@dawid-nowak dawid-nowak Aug 24, 2026

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.

How about just adding and keeping the interface as it was.

Either adding :
async {}.await;
or
#[allow(clippy::unused_async_trait_impl)]

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.

2 participants