rust-lang / rust-lang/rust-clippy

pub keyword incorrectly highlighted as changed in suggestion for must_use_candidate

Open
#17,669 2 comments 0 reactions 1 assignee View on GitHub

@gwosti is already working on this.

Since Sep 1, 2026.

C-bug D-confusing L-suggestion
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

when enabling the must_use_candidates lint in one of my projects (https://github.com/m4rch3n1ng/mayfig) i saw that the pub keyword was highlighted in green as if it was a changed value and the line was marked with ~.

Reproducer

clone this repo: https://github.com/m4rch3n1ng/must-use-repro and then run cargo clippy. for some reason i cannot reproduce it when just writing the equivalent code into a file, but cloning that repo reproduces the issue for me.

Current output:

Image

Desired output:

in the suggestion the pub keyword should not be marked as green, and line 9 should not have a ~ at the left and line 8 should be a + instead of a ~

Version
rustc 1.99.0-beta.3 (cbae9b4ca 2026-08-28)
binary: rustc
commit-hash: cbae9b4cae2b108f6a3d18cfe6075714bb739463
commit-date: 2026-08-28
host: x86_64-unknown-linux-gnu
release: 1.99.0-beta.3
LLVM version: 23.1.0
Additional Labels

No response

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.