Unverified Commit 8013166c authored by david-perez's avatar david-perez Committed by GitHub
Browse files

Don't use `#[allow(unused)]` in generated code (#2211)

Most usages are in the server constrained types generators, where
`#[allow(dead_code)]` suffices and makes the intent clearer.

See https://stackoverflow.com/a/64556868
parent a0b2ac6b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ internal class EndpointResolverGenerator(stdlib: List<CustomRuntimeFunction>, ru

    private fun resolverFnBody(endpointRuleSet: EndpointRuleSet) = writable {
        endpointRuleSet.parameters.toList().forEach {
            Attribute.AllowUnused.render(this)
            Attribute.AllowUnusedVariables.render(this)
            rust("let ${it.memberName()} = &$ParamsName.${it.memberName()};")
        }
        generateRulesList(endpointRuleSet.rules)(this)
@@ -291,7 +291,7 @@ internal class EndpointResolverGenerator(stdlib: List<CustomRuntimeFunction>, ru
                    fn.type() is Type.Option ||
                        // TODO(https://github.com/awslabs/smithy/pull/1504): ReterminusCore bug: substring should return `Option<String>`:
                        (fn as Function).name == "substring" -> {
                        Attribute.AllowUnused.render(this)
                        Attribute.AllowUnusedVariables.render(this)
                        rustTemplate(
                            "if let Some($resultName) = #{target:W} { #{next:W} }",
                            "target" to target,
+0 −1
Original line number Diff line number Diff line
@@ -458,7 +458,6 @@ class Attribute(val inner: Writable) {
        val AllowDeprecated = Attribute(allow("deprecated"))
        val AllowIrrefutableLetPatterns = Attribute(allow("irrefutable_let_patterns"))
        val AllowUnreachableCode = Attribute(allow("unreachable_code"))
        val AllowUnused = Attribute(allow("unused"))
        val AllowUnusedImports = Attribute(allow("unused_imports"))
        val AllowUnusedMut = Attribute(allow("unused_mut"))
        val AllowUnusedVariables = Attribute(allow("unused_variables"))
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ class ConstrainedBlobGenerator(
        constrainedTypeMetadata.render(writer)
        writer.rust("struct $name(pub(crate) $inner);")
        if (constrainedTypeVisibility == Visibility.PUBCRATE) {
            Attribute.AllowUnused.render(writer)
            Attribute.AllowDeadCode.render(writer)
        }
        writer.rust(
            """
+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ class ConstrainedCollectionGenerator(
            *codegenScope,
        )
        if (constrainedTypeVisibility == Visibility.PUBCRATE) {
            Attribute.AllowUnused.render(writer)
            Attribute.AllowDeadCode.render(writer)
        }

        writer.rustTemplate(
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ class ConstrainedMapGenerator(
        constrainedTypeMetadata.render(writer)
        writer.rustTemplate("struct $name(pub(crate) $inner);", *codegenScope)
        if (constrainedTypeVisibility == Visibility.PUBCRATE) {
            Attribute.AllowUnused.render(writer)
            Attribute.AllowDeadCode.render(writer)
        }
        writer.rustTemplate(
            """
Loading