-
Notifications
You must be signed in to change notification settings - Fork 214
Add decorator and setting to set hints.mostly-unused
#4243
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ba98f30
Add decorator and setting to set hints.mostly-unused
landonxjames 653c84d
Merge branch 'main' into landonxjames/hint
landonxjames 05ee5de
Merge branch 'main' into landonxjames/hint
landonxjames d45e041
Add changelog entry
landonxjames 550bc3f
Add a few more crates with hints.mostly-unused
landonxjames 24d314f
Fix bug with enum customizations in TsServer codegen
landonxjames abe99fc
Merge branch 'main' into landonxjames/hint
landonxjames 10a2c01
Remove hinstMostlyUnused from smithy-build.json
landonxjames 4ef2984
Merge branch 'main' into landonxjames/hint
landonxjames File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
applies_to: | ||
- aws-sdk-rust | ||
- client | ||
authors: | ||
- landonxjames | ||
references: | ||
- smithy-rs#4208 | ||
breaking: false | ||
new_feature: true | ||
bug_fix: false | ||
--- | ||
Add the ability to insert `hints.mostly-unused = true` in Cargo.toml. Enable this hint for the below crates: | ||
- aws-sd-cloudformation | ||
- aws-sdk-dynamodb | ||
- aws-sdk-ec2 | ||
- aws-sdk-s3 | ||
- aws-sdk-sns | ||
- aws-sdk-sqs | ||
- aws-sdk-ssm | ||
- aws-sdk-sts | ||
|
||
See more information about this hint at https://blog.rust-lang.org/inside-rust/2025/07/15/call-for-testing-hint-mostly-unused/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,13 @@ | |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
aws.services= | ||
aws.services.hints.mostlyUnused=\ | ||
landonxjames marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably want to remove this. |
||
aws-sd-cloudformation,\ | ||
aws-sdk-dynamodb,\ | ||
aws-sdk-ec2,\ | ||
aws-sdk-s3,\ | ||
aws-sdk-sns,\ | ||
aws-sdk-sqs,\ | ||
aws-sdk-ssm,\ | ||
aws-sdk-sts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...oftware/amazon/smithy/rust/codegen/client/smithy/customizations/ManifestHintsDecorator.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.client.smithy.customizations | ||
|
||
import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext | ||
import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator | ||
import software.amazon.smithy.rust.codegen.core.smithy.generators.ManifestCustomizations | ||
|
||
/** | ||
* See https://blog.rust-lang.org/inside-rust/2025/07/15/call-for-testing-hint-mostly-unused/ for more information | ||
*/ | ||
data class ManifestHintsSettings( | ||
val mostlyUnused: Boolean? = null, | ||
) | ||
|
||
fun ManifestHintsSettings.asMap(): Map<String, Any> { | ||
val inner = | ||
listOfNotNull( | ||
mostlyUnused?.let { "mostly-unused" to it }, | ||
).toMap() | ||
return mapOf("hints" to inner) | ||
} | ||
|
||
/** | ||
* Write compilation hints metdata settings into Cargo.toml. | ||
* | ||
* # Notes | ||
* This decorator is not used by default, code generators must manually configure and include it in their builds. | ||
*/ | ||
class ManifestHintsDecorator(private val manifestHintsSettings: ManifestHintsSettings) : ClientCodegenDecorator { | ||
override val name: String = "ManifestHintsDecorator" | ||
override val order: Byte = 0 | ||
|
||
override fun crateManifestCustomizations(codegenContext: ClientCodegenContext): ManifestCustomizations { | ||
return manifestHintsSettings.asMap() | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't end up needing this after I moved the service list to
gradle.properties
, but seemed like it could be a useful utility in the future, so I left it.