rust-lang / rust-lang/rust-clippy

restriction lint: implicit drop

Open
#13,982 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

detect all locations where drop is called implicitly and suggest turning it into an explicit drop.

possibly has a setting to only warn about locations where a needs_drop value is dropped.

Advantage

would be handy as a learning and debugging tool, allowing you to essentially desugar your code.

Drawbacks

non-trivial implementation for a lint that will never be used in production code.

Example
fn main() {
  let s = "Hello, World".to_string();
  println!("{s}");
}

Could be written as:

fn main() {
  let s = "Hello, World".to_string();
  println!("{s}");
  drop(s);
}

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

The issue does not name files, tests, or an entry point. Start by locating Clippy's lint registration and existing lints related to ownership or drops, then compare their handling with the example. Done means implicit drops are detected and an explicit drop suggestion is produced, with an optional needs_drop restriction if that scope is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.