refactor: remove paste dependency#114
Merged
Merged
Conversation
メンテナンスが放棄された paste (RUSTSEC-2024-0436) への依存を削除する。 代替 crate への移行や内製 paste の追加は行わず、識別子の連結を不要化する 方針で置き換える。 - 各 macro_rules\! の `paste::paste\!` による識別子連結を廃止し、 連結済みの識別子(fn 名・trait 名・メソッド名・エラー型)を 呼び出し側から明示的に渡す形式に変更 - 生成される識別子は従来と完全に同一のため、公開 API への影響なし - 副次効果として、生成識別子がソース上に実名で現れ grep 可能になる Closes #95 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR removes the unmaintained paste crate from the workspace by refactoring macros that previously relied on identifier concatenation, and instead passing the needed identifiers explicitly at macro invocation sites across serde_valid, serde_valid_derive, and serde_valid_literal.
Changes:
- Removed
pastefrom workspace + crate manifests and replacedpaste::paste!usage with explicit ident parameters inmacro_rules!macros. - Updated composited-validation helper macros in
serde_validto accept explicit trait/method/error identifiers (via ValidateX::validate_x;, etc.). - Updated derive-macro validator extractors to call explicit composited traits/methods (instead of generating names via
paste).
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/serde_valid/src/validation/numeric/multiple_of.rs | Updates composited-validation macro invocation to pass explicit trait/method/error identifiers. |
| crates/serde_valid/src/validation/numeric/minimum.rs | Same refactor for minimum composited validation generation. |
| crates/serde_valid/src/validation/numeric/maximum.rs | Same refactor for maximum composited validation generation. |
| crates/serde_valid/src/validation/numeric/exclusive_minimum.rs | Same refactor for exclusive_minimum composited validation generation. |
| crates/serde_valid/src/validation/numeric/exclusive_maximum.rs | Same refactor for exclusive_maximum composited validation generation. |
| crates/serde_valid/src/validation/composited.rs | Removes paste usage by passing explicit error type identifiers into impl_into_error!. |
| crates/serde_valid/src/validation/array.rs | Removes paste usage by passing explicit trait/method/error identifiers into impl_validate_array_length_items!. |
| crates/serde_valid/src/validation.rs | Refactors composited-validation macros to avoid identifier concatenation by taking explicit trait/method inputs. |
| crates/serde_valid/Cargo.toml | Drops paste dependency from serde_valid. |
| crates/serde_valid_literal/src/number.rs | Removes paste usage by explicitly mapping primitive types to Number variants in macro invocations. |
| crates/serde_valid_literal/Cargo.toml | Drops paste dependency from serde_valid_literal. |
| crates/serde_valid_derive/src/attribute/field_validate/string/length.rs | Refactors validator-extraction macro to accept explicit generated function/trait/method names. |
| crates/serde_valid_derive/src/attribute/field_validate/object/size_properties.rs | Same refactor pattern for object size validators. |
| crates/serde_valid_derive/src/attribute/field_validate/numeric/range.rs | Same refactor pattern for numeric range validators. |
| crates/serde_valid_derive/src/attribute/field_validate/array/length_items.rs | Same refactor pattern for array length validators. |
| crates/serde_valid_derive/Cargo.toml | Drops paste dependency from serde_valid_derive. |
| Cargo.toml | Drops paste from workspace dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+46
to
+47
| use ::serde_valid::validation::IntoError; | ||
| use ::serde_valid::validation::error::FormatDefault; |
Comment on lines
+46
to
+47
| use ::serde_valid::validation::IntoError; | ||
| use ::serde_valid::validation::error::FormatDefault; |
Comment on lines
+44
to
+45
| use ::serde_valid::validation::IntoError; | ||
| use ::serde_valid::validation::error::FormatDefault; |
| #field_ident, | ||
| #limit, | ||
| ) { | ||
| use ::serde_valid::validation::error::FormatDefault; |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Removes the dependency on
paste(unmaintained, RUSTSEC-2024-0436) without migrating to a fork or adding any new dependency. Instead of replacingpastewith an equivalent, this change eliminates the need for identifier concatenation itself.macro_rules!that usedpaste::paste!to derive identifiers (extract_numeric_maximum_validator,ValidateCompositedMaxLength,Number::I8, etc.) now receives the pre-concatenated identifiers explicitly from the invocation siteserde_valid_literal:impl_from_trait!(i8 => I8)(26 invocations)serde_valid_derive: validator-extraction macros take the generated fn / trait / method names as arguments (4 macros)serde_valid:impl_composited_validation_1args!gains avia ValidateMaxLength::validate_max_length;clause;impl_generic_composited_validation_1args!,impl_into_error!, andimpl_validate_array_length_items!take explicit identsThis follows the same policy as #113: with several crates in the ecosystem being abandoned, this project prefers removing small dependencies over migrating to successor forks.
Closes #95
Validation
cargo build --workspace --all-features— passescargo test --workspace --all-features— all 32 test suites pass (including doc-tests, which exercise the derive macros)cargo fmt -- --check/cargo clippy --workspace --all-features— zero warningscargo tree -i paste— package no longer exists in the dependency graphcargo deny check advisories—advisories ok(the exact command from the issue report; RUSTSEC-2024-0436 resolved)🤖 Generated with Claude Code