Skip to content

refactor: remove proc-macro-error2 dependency#113

Merged
ya7010 merged 1 commit into
mainfrom
refactor/replace-proc-macro-error2
Jun 10, 2026
Merged

refactor: remove proc-macro-error2 dependency#113
ya7010 merged 1 commit into
mainfrom
refactor/replace-proc-macro-error2

Conversation

@ya7010

@ya7010 ya7010 commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Removes the proc-macro-error2 dependency to reduce reliance on external crates whose maintenance status is uncertain, and unifies all derive-macro error handling under the existing crate::Error / to_compile_errors() mechanism.

  • Made SingleIdentPath::new / NamedField::new / UnnamedField::new return Result<_, crate::Error>, completely eliminating panic-based abort! (no panic path remains other than parse_macro_input!)
  • Changed collect_serde_rename_map to return Result<RenameMap, crate::Errors>, propagating with ? at its callers (named_struct_derive / enum_derive)
  • Removed the #[proc_macro_error] attribute and the dependency declarations from Cargo.toml
  • Error messages and spans are identical to before; since errors now flow through the existing Errors collection mechanism, multiple errors can be reported at once

Under the hood, proc-macro-error2 is just a wrapper that catches abort! panics via catch_unwind and renders them as compile_error!. This crate already has an equivalent Result-based mechanism, so the dependency could be replaced without adding any custom implementation.

Closes #112

Validation

  • cargo build --workspace — passes
  • cargo test --workspace --all-features — all 32 test suites pass
  • cargo fmt -- --check / cargo clippy --workspace --all-features — zero warnings
  • cargo tree -p serde_valid_derive — no remaining reference to proc-macro-error2
  • Manual check: compiled a test crate containing #[validate(foo::bar)] and confirmed the same span-accurate error output as before:
    error: Path(='foo::bar') must be single ident path.
     --> src/main.rs:5:16
      |
    5 |     #[validate(foo::bar)]
      |                ^^^
    

🤖 Generated with Claude Code

メンテナンス状況に左右される外部依存を排除するため、proc-macro-error2 を削除し、
既存の `crate::Error` / `to_compile_errors()` 機構にエラー処理を統一する。

- `SingleIdentPath::new` / `NamedField::new` / `UnnamedField::new` を
  `Result<_, crate::Error>` 化し、panic ベースの `abort\!` を排除
- `collect_serde_rename_map` を `Result<RenameMap, crate::Errors>` 化
- `#[proc_macro_error]` 属性と依存宣言を削除
- エラーメッセージと span は従来と同一の表示を維持

Closes #112

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ya7010
ya7010 merged commit 3c91417 into main Jun 10, 2026
3 checks passed
@ya7010
ya7010 deleted the refactor/replace-proc-macro-error2 branch June 10, 2026 10:30
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.

RUSTSEC-2026-0173: proc-macro-error2 is unmaintained

1 participant