بنقرة واحدة
rmc-rename-symbol
Preview a Rust symbol rename — exact reference set & refactor probe.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Preview a Rust symbol rename — exact reference set & refactor probe.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Audit a Rust crate's public API.
Enforce Rust crate-edge rules.
Audit Rust attributes and doc-comments.
Rust fn-level call graphs.
Task-conditioned workspace subgraph — nodes, edges, hierarchy.
Rust complexity hotspots by blast radius.
| name | rmc-rename-symbol |
| description | Preview a Rust symbol rename — exact reference set & refactor probe. |
| argument-hint | <symbol-name> [new-name] |
| allowed-tools | Read, mcp__rust-code-mcp__* |
rename_symbol is rust-analyzer's rename engine run dry. It returns the exact
set of byte-precise edits and file moves that would be applied if you
committed the rename. Nothing is written to disk.
That makes it useful for more than renaming. It is the highest-precision single-symbol reference inventory rust-analyzer can produce, plus a safety probe for whether a given refactor is even legal.
For "what is this symbol's qualified name?" → rmc-find-symbol. For broader
fan-in (importers, consumer crates, Test/Other breakdown) → rmc-symbol-forensics.
For composing this into a refactor decision → rmc-refactor-plan.
# No hypergraph required. rust-analyzer must load the project successfully.
# `directory` must be the Cargo project root (or workspace root with the
# crate in scope).
rename_symbol(symbol_name=<exact_short_name>,
new_name=<identifier>,
directory=<absolute_path>,
file_path=<optional_path>,
line=<optional_1_based_line>,
column=<optional_1_based_column>)
file_path, line, and
column to disambiguate.file_path, line, and column are optional but must be provided together.
When present, the tool bypasses name search and asks rust-analyzer to rename
the symbol at that concrete position.edits: a list of file:start_line:start_col-end_line:end_col → "new_text"
for every textual reference rust-analyzer would touch.file_moves: any module file moves required (e.g. renaming mod parser
may move parser.rs or parser/mod.rs).You want every place where Foo is referenced, including:
impl Foo for ...)use path components[Foo])Run the rename with new_name = symbol_name. The edit set is the full
reference inventory at byte precision.
rename_symbol(symbol_name=Foo, new_name=Foo, directory=...)
This is stricter than who_uses (hypergraph-driven, structural) and
narrower than find_references (which can include comment/doc-string
matches). When the three disagree, the difference is the signal:
rename_symbol has refs who_uses doesn't → those are macro-introduced.find_references has refs rename_symbol doesn't → those are comments / docs.Before you commit to a rename:
rename_symbol(symbol_name=Foo, new_name=Foo_PROBE_NAME, directory=...)
If rust-analyzer refuses, the reason tells you whether the rename is even possible. Common refusals:
Group edits by their crate path prefix (crates/<x>/...).
This is faster than running who_imports + who_uses_summary when you just
need a yes/no on "does this leak outside the crate?".
When who_uses + find_references look empty but you're unsure:
rename_symbol(symbol_name=Foo, new_name=Foo_dead_check, directory=...)
If the only edit is the definition site itself, the symbol really is unreferenced. If RA returns more sites, you've caught references the other tools missed — usually macro-introduced.
For module-level symbols, file_moves reveals the required filesystem
reorganization. Run the rename and inspect file_moves before doing anything
manually:
rename_symbol(symbol_name=parser, new_name=lexer, directory=...)
→ file_moves: [src/parser.rs → src/lexer.rs]
Renaming a trait method gives you, in one edit set:
impl Trait for T { fn method... } sitedyn T sites
RA can resolve)This is the only built-in way to enumerate trait dispatch points without walking impls by hand.
Save the rename-to-self edit set as JSON before a refactor, re-run after, diff:
Useful for verifying that a refactor touched only what was intended.
| Result | Interpretation |
|---|---|
Ambiguous symbol error with candidate list | Rerun with the candidate's file_path, line, and column. |
rust-analyzer rename refused: <reason> | Refactor as proposed is illegal. Read the reason; the right move is often to rename a wrapper, not the inner item. |
| Edits = 1 (definition site only) | Symbol unreferenced → safe-to-delete candidate. Confirm with who_uses and find_references. |
| Edits all inside one crate | Internal refactor — go. |
| Edits span 2+ crates | Public API change — coordinate consumers / SemVer. |
file_moves non-empty | Module rename — plan the filesystem reorganization. |
Edit count >> who_uses count | Macro-expanded refs in the gap. Trust rename_symbol. |
| Signal | Means |
|---|---|
Edits live entirely in tests/ or under #[cfg(test)] | Test-only symbol; demote visibility or gate with #[cfg(test)]. |
| RA refuses with a "macro" reason | Symbol is generated; rename the macro / its input, not the expansion. |
| Edits cluster in one foreign crate | That crate is the primary consumer; consider co-locating the symbol there. |
rename_symbol succeeds with 0 edits | Symbol exists but is structurally unreachable (e.g. behind a disabled cfg). |
When invoked, return:
Symbol: <name>
Resolution: <exact @ file:line | ambiguous: N candidates>
Edits: <n> across <m> files in <k> crates
File moves: <n>
Refactor legality: <ok | refused: <reason>>
If the user wants the rename applied, also dump:
Text edits:
<file>:<l>:<c>-<l>:<c> → "<new_text>"
...
File system changes:
<from> → (anchor: <a>) <to>
...
If invoked for use cases 1–7, frame the output around the question asked (e.g. for Use 4, lead with "X is dead: only the definition site appears in the rename edit set").
file_path, line, and column.proc_macro-introduced names are invisible.find_references covers those instead).