rust-lang / rust-lang/rust-analyzer

Feature request: Option to show inlay hints for implicit `Drop` calls

Open
#15,785 6 comments 1 reaction 1 assignee View on GitHub

@jnyfah is already working on this.

Since Feb 7, 2025.

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

Description

I feel like having an option to explicitly show any potentially implicit calls to Drop() would be a nice option to have.

For example, in a function like

fn foo(x: std::sync::Mutex<bool>) {
    let xx = x.lock().unwrap();
    *xx = !*xx;
    // add an inlay hint here showing that xx gets dropped
}

it might be nice to be able to hover over something to see the Drop implementation for MutexGuard, and make it explicit (at least in the editor) where certain values are being dropped. (Which could also be helpful for rust beginners.) This is probably something that should only be done when the type has a non-trivial Drop impl, however.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.