rust-lang / rust-lang/rust-analyzer

Feature request - action to add deprecation to item

Open
#12,291 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-assists C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

I'd like to improve the experience of incrementally migrating bits of a codebase. A workflow I'll use is:

  • write the new implementation
  • mark the old implementation as deprecated and add '#[allow(deprecated)] to all of the uses
  • migrate each use incrementally

This allows the migration process to be split up into multiple, smaller PRs, which are easier to review, without breaking the build in between.

However, in some cases, there are hundreds/thousands of uses, and it takes a long time to go through and manually add #[allow(deprecated)] to the old usages.

I'd be keen to see a code action for something like: "deprecate and whitelist usages" on items. For example:

fn old_function()  {
  println!("old implementation")
}

fn main() {
  old_function();
}

would become

#[deprecated]
fn old_function()  {
  println!("old implementation")
}

fn main() {
  #[allow(deprecated)]
  old_function();
}

Does this sound like something useful? If so I'd be happy to work on a PR

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating rust-analyzer's existing code-action handling for Rust deprecation diagnostics and item usages. Use the Rust example in the issue as the acceptance case: the action should deprecate the selected item and add #[allow(deprecated)] to its usages, with the resulting code showing the requested migration workflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.