SeaQL/sea-orm

Refactor macro implmentions

开放

#3,119 创建于 2026年7月7日

 (6 条评论) (0 个反应) (1 位负责人)Rust (718 个派生)auto 404
good first issuehelp-wanted

仓库指标

星标
 (9,827 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

I did some refactoring in #3118, but the current macro implementation is still quite messy.

The refactoring mainly split the code that mixed parsing and expansion into separate steps.

Ideally, we should remove bae. We could consider using darling instead, or just write the parsing code manually. The current macro parser supports all possible combinations, and I worked around that by adding an extra normalization step, but it would be better to clean up the related code.

There are also many other things that can be simplified. I noticed a lot of recurring patterns like duplicated logic across branches, using parse(&str) instead of syn::parse_quote, using manually constructed strings and Idents instead of format_ident, and converting types such as Type or Ident into String for comparison and then converting them back, rather than comparing them directly.

I also noticed that some state can be derived rather than stored.

For contributors who want to help with this, I would suggest starting with small, focused changes, ideally by addressing one category of issues at a time. Furthermore, please don't open LLM-generated PRs.

贡献者指南