rust-lang / rust-lang/rust-analyzer

Idea (Quickfix): "Add todo!() to end of your function"

Open
#18,581 1 comment 2 reactions 1 assignee View on GitHub

@pickx is already working on this.

Since Dec 18, 2024.

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

Description

It would be nice if rust-analyzer provides a code action (quickfix) which adds todo!() when:

  • No return sentence
  • The function should return something (not -> ()), but it doesn't return anything
// Case 1: Should suggest, because the function looks like it's not completed
fn foo() -> String {
  doing_things();
  // ...
  // add todo!() here
}

// Case 2: Should not suggest, because it's more likely an user issue
fn foo() -> String {
  doing_things();

  return 42;
}

// Case 3: Should not suggest, because it's more likely an user issue
fn foo() -> String {
  doing_things();

  return;
}

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.