Skip to content

[Rust-Axum] Adapt Rust 1.100.x: fix lint error due to Never type - #25694

Open
linxGnu wants to merge 2 commits into
OpenAPITools:masterfrom
linxGnu:fix
Open

linxGnu wants to merge 2 commits into
OpenAPITools:masterfrom
linxGnu:fix

Conversation

@linxGnu

@linxGnu linxGnu commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Ran integration test. Kindly ping @wing328 to review

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes lint and formatting errors in the rust-axum generator when building with Rust 1.100.x.

  • String fields are now parsed with val.to_string() instead of <String as std::str::FromStr>::from_str(val), eliminating the clippy::redundant_clone warning caused by the new Never type. UUID fields keep the FromStr path with the lint allow.
  • Regenerated all rust-axum samples, including applying rustfmt import ordering and missing-semicolon fixes.

Written for commit b0cfa43. Summary will update on new commits.

View guided diff

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 91 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs">

<violation number="1" location="samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs:2663">
P3: The match arms added to `ObjectUntypedProps::from_str` have inconsistent indentation (24/23 spaces instead of 20), so this regenerated sample will not match rustfmt output. Fix the template that emits these long one-line arms so the generated sample is properly indented.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

#[allow(clippy::redundant_clone)]
"required_untyped" => intermediate_rep.required_untyped.push(<crate::types::Object as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
#[allow(clippy::redundant_clone)]
"required_untyped" => intermediate_rep.required_untyped.push(<crate::types::Object as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The match arms added to ObjectUntypedProps::from_str have inconsistent indentation (24/23 spaces instead of 20), so this regenerated sample will not match rustfmt output. Fix the template that emits these long one-line arms so the generated sample is properly indented.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs, line 2663:

<comment>The match arms added to `ObjectUntypedProps::from_str` have inconsistent indentation (24/23 spaces instead of 20), so this regenerated sample will not match rustfmt output. Fix the template that emits these long one-line arms so the generated sample is properly indented.</comment>

<file context>
@@ -2661,20 +2652,20 @@ impl std::str::FromStr for ObjectUntypedProps {
-                    #[allow(clippy::redundant_clone)]
-                    "required_untyped" => intermediate_rep.required_untyped.push(<crate::types::Object as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
+                        #[allow(clippy::redundant_clone)]
+                       "required_untyped" => intermediate_rep.required_untyped.push(<crate::types::Object as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
                     "required_untyped_nullable" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ObjectUntypedProps".to_string()),
-                    #[allow(clippy::redundant_clone)]
</file context>
Suggested change
"required_untyped" => intermediate_rep.required_untyped.push(<crate::types::Object as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
"required_untyped" => intermediate_rep.required_untyped.push(<crate::types::Object as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/main/resources/rust-axum/models.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/rust-axum/models.mustache:1325">
P3: The UUID arm is emitted as one long line, leaving the generated sample unformatted beside the wrapped `FormatTest` arm. Wrap the expression in the template and regenerate the sample.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

{{/isUuid}}
{{#isUuid}}
#[allow(clippy::redundant_clone)]
"{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The UUID arm is emitted as one long line, leaving the generated sample unformatted beside the wrapped FormatTest arm. Wrap the expression in the template and regenerate the sample.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/rust-axum/models.mustache, line 1325:

<comment>The UUID arm is emitted as one long line, leaving the generated sample unformatted beside the wrapped `FormatTest` arm. Wrap the expression in the template and regenerate the sample.</comment>

<file context>
@@ -1317,7 +1317,13 @@ impl std::str::FromStr for {{{classname}}} {
+                     {{/isUuid}}
+                     {{#isUuid}}
+                       #[allow(clippy::redundant_clone)]
+                       "{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
+                     {{/isUuid}}
                     {{/isString}}
</file context>

@linxGnu

linxGnu commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

It looks ok. Please help me merge this PR @wing328 . Thank you

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant