Skip to content

feat: add duplicate_fn_bodies lint - #17527

Open
orielhaim wants to merge 1 commit into
rust-lang:masterfrom
orielhaim:master
Open

feat: add duplicate_fn_bodies lint#17527
orielhaim wants to merge 1 commit into
rust-lang:masterfrom
orielhaim:master

Conversation

@orielhaim

@orielhaim orielhaim commented Aug 8, 2026

Copy link
Copy Markdown

Motivation

This adds a small first step towards detecting duplicated code in Clippy.

duplicate_fn_bodies looks for functions in the same crate whose bodies are textually identical, ignoring whitespace and comments.

For now I intentionally kept the lint very conservative. It only handles Type-1 style clones: renamed locals, changed literals, reordered statements, etc. are considered different bodies. I wanted to start with the case that can be detected with very high confidence before considering anything more structural.

Checklist

  • Followed lint naming conventions
  • Added passing UI tests (including committed .stderr file)
  • cargo test passes locally
  • Executed cargo dev update_lints
  • Added lint documentation
  • Ran cargo dev fmt

changelog: new lint: [duplicate_fn_bodies]

@rustbot rustbot added the S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. label Aug 8, 2026
@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome!

You should hear from one of our reviewers after this PR gets at least 2 reviews from the community.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Lintcheck changes for c389da1

Lint Added Removed Changed
clippy::duplicate_fn_bodies 2066 0 0

This comment will be updated if you push new changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants