Skip to content

Commit dffac1b

Browse files
author
Fahad Zubair
committed
Add reference to Github issue in comments
1 parent bf02d60 commit dffac1b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderGenerator.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,17 @@ class ServerBuilderGenerator(
351351
if (!constrainedTypeHoldsFinalType(member)) varExpr = "($varExpr).into()"
352352

353353
if (wrapInMaybeConstrained) {
354+
// TODO(https://github.com/rust-lang/rust-clippy/issues/14789):
354355
// Temporary fix for `#[allow(clippy::redundant_closure)]` not working in `rustc` version 1.82.
355356
// The issue occurs specifically when we generate code in the form:
356357
// ```rust
357358
// input.map(|v| MaybeConstrained(v))
358359
// ```
359360
// This pattern triggers a clippy warning about redundant closures, even with the allow attribute.
360-
// For this specific pattern, we directly use the constructor function reference.
361+
// For this specific pattern, we directly use the constructor function reference:
362+
// ```rust
363+
// input.map(MaybeConstrained)
364+
// ```
361365
// Other cases like `Box::new(v)` or `v.into()` are valid closure usages and remain unchanged.
362366
if (symbol.isOptional() && varExpr == "v") {
363367
rust("input.map($maybeConstrainedVariant)")

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderGeneratorCommon.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,16 @@ fun generateFallbackCodeToDefaultValue(
8686
publicConstrainedTypes: Boolean,
8787
) {
8888
val targetShape = model.expectShape(member.target)
89+
// TODO(https://github.com/rust-lang/rust-clippy/issues/14789):
8990
// Temporary fix for `#[allow(clippy::redundant_closure)]` not working in `rustc` version 1.82.
9091
// The issue occurs specifically when we generate code in the form:
9192
// ```rust
9293
// .unwrap_or_else(HashMap::new())
9394
// ```
95+
// Instead of the linter suggested code:
96+
// ```rust
97+
// .unwrap_or_default()
98+
// ```
9499
if (isTargetListOrMap(targetShape, member)) {
95100
writer.rustTemplate(".unwrap_or_default()")
96101
return

0 commit comments

Comments
 (0)