Fix nightly clippy collapsible_match errors in codegen#518
Fix nightly clippy collapsible_match errors in codegen#518
collapsible_match errors in codegen#518Conversation
…rors Co-authored-by: Nugine <30099658+Nugine@users.noreply.github.com>
collapsible_match errors in codegen
There was a problem hiding this comment.
Pull request overview
Updates the Rust code generator to satisfy newer nightly Clippy collapsible_match linting by rewriting nested if checks inside match arms as match guards, keeping the generated behavior the same while unblocking CI.
Changes:
- Refactor
can_derive_serdeto use guarded match arms for recursiveStructchecks. - Refactor
can_derive_defaultto use a guarded match arm for theCachedTagsspecial-case. - Refactor
DtoExt::ignore_empty_stringscodegen to use guarded match arms forAlias(String)and optionalStrEnumhandling.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@copilot Work around the lint by Keep each match arm corresponding to a |
…per rust::Type Co-authored-by: Nugine <30099658+Nugine@users.noreply.github.com>
... Done in 399e232. The Each case keeps one arm per
|
Nightly Rust clippy now enforces
collapsible_match, causing 4 compile errors incodegen/src/v1/dto.rsthat break CI.Changes
Each fix keeps one
matcharm perrust::Type. The 4 sites indto.rsare addressed as follows:Structincan_derive_serde: Inverted the condition so the "pass" case is in theif-body and the early exit is inelse:Providedincan_derive_default: Eliminated the nestedifentirely with a single-expression return:Aliasinignore_empty_strings: Applied De Morgan's law to invert the compound condition, placing "pass" in theif-body and the action inelse(the compound||avoids triggeringclippy::if_not_else):StrEnuminignore_empty_strings: The simple boolean conditionfield.option_typecannot be inverted without triggeringclippy::if_not_else. Added#[allow(clippy::collapsible_match)]to the containingcodegen_dto_extfunction as a targeted workaround.Semantics are unchanged across all 4 sites.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.