-
Notifications
You must be signed in to change notification settings - Fork 300
Open
Description
Description
The #[derive(OpenApi)] macro generates code that triggers a clippy warning for needless_for_each, which cannot be suppressed at the derive site and requires a module-level #![allow(clippy::needless_for_each)] to silence.
Steps to Reproduce:
- Create a struct with #[derive(OpenApi)]
- Run
cargo clippy
with pedantic lints enabled
Example Code:
use utoipa::OpenApi;
#[derive(OpenApi)]
#[openapi(
paths(),
components(),
tags((name = "api", description = "API")),
info(title = "Test API", version = "1.0.0")
)]
struct ApiDoc;
Expected Behavior:
No clippy warnings should be generated from derive macro code.
Actual Behavior:
warning: needless use of `for_each`
--> src/main.rs:XX:XX
|
XX | #[derive(OpenApi)]
| ^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_for_each
= note: this warning originates in the derive macro `OpenApi`
Environment:
utoipa version: 5.4.0
Rust version: nightly (rustc 1.90.0-nightly (28f1c8079 2025-06-24))
Clippy: nightly (rustc 1.90.0-nightly (28f1c8079 2025-06-24))
Workaround:
Currently requires adding #![allow(clippy::needless_for_each)] at the module level.
Suggested Fix:
Use a for loop instead of for_each where appropriate
rblaine95, dlrobson, BrainBlasted, secufoe and daflyinbed
Metadata
Metadata
Assignees
Labels
No labels