-
Notifications
You must be signed in to change notification settings - Fork 210
Fix redundant closure warnings in Rust 1.82 #4125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
18c82b5
to
4597059
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
...otlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderGenerator.kt
Show resolved
Hide resolved
...software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderGeneratorCommon.kt
Show resolved
Hide resolved
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
22a3c5d
to
045dcb1
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
Problem
In Rust 1.82, the
#[allow(clippy::redundant_closure)]
attribute is not functioning as intended, causing warnings that are elevated to errors in our build process. Specifically, when generating code in the form:Clippy still reports a redundant closure error despite the allow attribute.
Solution
This PR implements a temporary workaround until the Clippy issue is fixed. Instead of relying on the allow attribute, we now generate code that follows Clippy's recommendation by using function references directly:
For collection types like
Vec
andHashMap
, we're using.unwrap_or_default()
instead of closure-wrapped constructors.Implementation Details
Box::new
,.into()
)Testing
The workaround will be revisited once the Clippy issue is resolved in a future Rust version.