Skip to content

refactor: remove paste dependency#114

Merged
ya7010 merged 1 commit into
mainfrom
refactor/remove-paste
Jun 10, 2026
Merged

refactor: remove paste dependency#114
ya7010 merged 1 commit into
mainfrom
refactor/remove-paste

Conversation

@ya7010

@ya7010 ya7010 commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Removes the dependency on paste (unmaintained, RUSTSEC-2024-0436) without migrating to a fork or adding any new dependency. Instead of replacing paste with an equivalent, this change eliminates the need for identifier concatenation itself.

  • Every macro_rules! that used paste::paste! to derive identifiers (extract_numeric_maximum_validator, ValidateCompositedMaxLength, Number::I8, etc.) now receives the pre-concatenated identifiers explicitly from the invocation site
    • serde_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 a via ValidateMaxLength::validate_max_length; clause; impl_generic_composited_validation_1args!, impl_into_error!, and impl_validate_array_length_items! take explicit idents
  • All generated identifiers are byte-for-byte identical to before, so there is no public API change
  • As a side effect, previously un-greppable generated identifiers now appear verbatim in the source, improving searchability

This 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 — passes
  • cargo 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 warnings
  • cargo tree -i paste — package no longer exists in the dependency graph
  • cargo deny check advisoriesadvisories ok (the exact command from the issue report; RUSTSEC-2024-0436 resolved)

🤖 Generated with Claude Code

メンテナンスが放棄された 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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 paste from workspace + crate manifests and replaced paste::paste! usage with explicit ident parameters in macro_rules! macros.
  • Updated composited-validation helper macros in serde_valid to 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;
@ya7010
ya7010 merged commit 1b5ca5e into main Jun 10, 2026
4 checks passed
@ya7010
ya7010 deleted the refactor/remove-paste branch June 10, 2026 12:04
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.

dependency paste - no longer maintained

2 participants