0xPlaygrounds / 0xPlaygrounds/rig

Remove the redundant `tool_macro` alias for `#[rig_tool]`

Offen Anfängerfreundlich
#2,452 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
8.6k
Forks
959
Ø Merge
4 Std. 32 Min.
Gemergte PRs (30 T.)
117

Beschreibung

`#[rig_tool]` is re-exported under a second name, `tool_macro`, from all three crate roots. There is only one macro — `rig_derive::rig_tool` (`crates/rig-derive/src/lib.rs:148`), the only `#[proc_macro_attribute]` of its kind — and both names point at it:

- `crates/rig-core/src/lib.rs:203` — `pub use rig_derive::{rig_tool, rig_tool as tool_macro};`
- `crates/rig-agent/src/lib.rs:87,90` — the same pair
- `src/lib.rs:251` — `pub use rig_derive::rig_tool as tool_macro;`

`tool_macro` has never been a distinct macro: `git log -S 'pub fn tool_macro'` across all refs returns nothing. The name first appears in #2197 (the rig-core / rig-agent facade split) purely as an alias, added beside the `rig_tool` re-export.

The cost is user confusion, which #2448 is the concrete instance of: the docs use one spelling and rig-derive's examples use the other, so a reader reasonably assumes they are two macros, or that one supersedes the other. Neither is true.

Nothing in the tree prefers `tool_macro`. Its only occurrences are the alias definitions and the tests written to pin that the alias resolves — `tests/core/tool_macro.rs` and `tests/fixtures/tool_facade/src/main.rs`, one of which does `use rig::tool_macro as rig_tool;` (`tests/providers/gemini/cassette/tool_definitions.rs:237`).

## Proposal

Delete `tool_macro` and keep `rig_tool`, the macro's real name — the one rig-derive defines, documents and uses in its examples, and the one that works identically whether you depend on `rig`, `rig-core` or `rig-agent`.

This is the same class of item #2429 cleared this cycle; it was missed there presumably because it carries no `#[deprecated]` and no persisted-record tolerance behind it. The change is the three re-export sites plus retargeting the alias-pinning tests to `rig_tool`, and a "Removed" entry in the migration guide.

Happy to open the PR if the direction is agreed.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

The issue identifies three files with the redundant alias: crates/rig-core/src/lib.rs, crates/rig-agent/src/lib.rs, and src/lib.rs. Start by removing the `tool_macro` alias lines from these files. Then, update the test files that reference the alias: tests/core/tool_macro.rs, tests/fixtures/tool_facade/src/main.rs, and tests/providers/gemini/cassette/tool_definitions.rs, changing `tool_macro` to `rig_tool`. Finally, verify the build passes with `cargo test` and add a 'Removed' note to the migration guide.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
backend-api-design
Issue-Typ
Refactoring
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
65/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.