rust-lang / rust-lang/rust-clippy

Nightly regression: `clippy --fix` does no edits but suggests running the same `clippy --fix` command

Open
#15,031 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

If I run any of these commands:

  • cargo clippy --fix --workspace --all-targets --all-features
  • cargo clippy --fix --example "custom-backend"
  • cargo clippy --fix --lib -p jj-lib

on https://github.com/jj-vcs/jj/tree/b09c243ba37a5ed9f05320de17b80ec74c69b02d, Clippy does not change anything in the repo, but suggests that I run clippy --fix again. E.g, it suggests:

  • "run cargo clippy --fix --example "custom-backend" to apply 1 suggestion" (which is the command I just ran).
  • "run cargo clippy --fix --lib -p jj-lib to apply 17 suggestions"

This seems to be connected with the mismatched_lifetime_syntaxes lint. A longer excerpt hidden inside <details> below. Again, in spite of it saying "Fixed", nothing is changed in the repo.

       Fixed lib/testutils/src/test_backend.rs (0 fixes)
warning: lifetime flowing from input to output with different syntax can be confusing
   --> lib/testutils/src/test_backend.rs:392:9
    |
392 |         &self,
    |         ^^^^^ this lifetime flows to the output
...
396 |     ) -> BackendResult<BoxStream<BackendResult<CopyRecord>>> {
    |                        ------------------------------------ the lifetime gets resolved as `'_`
    |
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
396 |     ) -> BackendResult<BoxStream<'_, BackendResult<CopyRecord>>> {
    |                                  +++

warning: `testutils` (lib test) generated 1 warning (run `cargo clippy --fix --lib -p testutils --tests` to apply 1 suggestion)
       Fixed cli/src/config.rs (0 fixes)
       Fixed cli/src/cli_util.rs (0 fixes)
       Fixed cli/src/template_parser.rs (0 fixes)
warning: lifetime flowing from input to output with different syntax can be confusing
   --> cli/src/cli_util.rs:827:40
    |
827 |     pub(crate) fn revset_parse_context(&self) -> RevsetParseContext {
    |                                        ^^^^^     ------------------ the lifetime gets resolved as `'_`
    |                                        |
    |                                        this lifetime flows to the output
    |
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
827 |     pub(crate) fn revset_parse_context(&self) -> RevsetParseContext<'_> {
    |                                                                    ++++

warning: lifetime flowing from input to output with different syntax can be confusing
    --> cli/src/cli_util.rs:1244:9
     |
1244 |         &mut self,
     |         ^^^^^^^^^ this lifetime flows to the output
1245 |     ) -> Result<(LockedWorkspace, Commit), CommandError> {
     |                  --------------- the lifetime gets resolved as `'_`
     |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
     |
1245 |     ) -> Result<(LockedWorkspace<'_>, Commit), CommandError> {
     |                                 ++++

warning: lifetime flowing from input to output with different syntax can be confusing
    --> cli/src/cli_util.rs:1259:9
     |
1259 |         &mut self,
     |         ^^^^^^^^^ this lifetime flows to the output
1260 |     ) -> Result<(LockedWorkspace, Commit), CommandError> {
     |                  --------------- the lifetime gets resolved as `'_`
     |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
     |
1260 |     ) -> Result<(LockedWorkspace<'_>, Commit), CommandError> {
     |                                 ++++

warning: lifetime flowing from input to output with different syntax can be confusing
    --> cli/src/cli_util.rs:2047:30
     |
2047 |     pub fn start_transaction(&mut self) -> WorkspaceCommandTransaction {
     |                              ^^^^^^^^^     --------------------------- the lifetime gets resolved as `'_`
     |                              |
     |                              this lifetime flows to the output
     |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
     |
2047 |     pub fn start_transaction(&mut self) -> WorkspaceCommandTransaction<'_> {
     |                                                                       ++++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> cli/src/config.rs:761:23
    |
761 |     pub fn split_name(&self) -> Cow<str> {
    |                       ^^^^^     -------- the lifetime gets resolved as `'_`
    |                       |
    |                       this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
761 |     pub fn split_name(&self) -> Cow<'_, str> {
    |                                     +++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> cli/src/config.rs:769:32
    |
769 |     pub fn split_name_and_args(&self) -> (Cow<str>, Cow<[String]>) {
    |                                ^^^^^      --------  ------------- the lifetimes get resolved as `'_`
    |                                |          |
    |                                |          the lifetimes get resolved as `'_`
    |                                this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
769 |     pub fn split_name_and_args(&self) -> (Cow<'_, str>, Cow<'_, [String]>) {
    |                                               +++           +++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> cli/src/template_parser.rs:422:32
    |
422 | fn parse_identifier_name(pair: Pair<Rule>) -> TemplateParseResult<&str> {
    |                                ^^^^^^^^^^                         ---- the lifetime gets resolved as `'_`
    |                                |
    |                                this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
422 | fn parse_identifier_name(pair: Pair<'_, Rule>) -> TemplateParseResult<&str> {
    |                                     +++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> cli/src/template_parser.rs:431:41
    |
431 | fn parse_formal_parameters(params_pair: Pair<Rule>) -> TemplateParseResult<Vec<&str>> {
    |                                         ^^^^^^^^^^                             ---- the lifetime gets resolved as `'_`
    |                                         |
    |                                         this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
431 | fn parse_formal_parameters(params_pair: Pair<'_, Rule>) -> TemplateParseResult<Vec<&str>> {
    |                                              +++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> cli/src/template_parser.rs:594:38
    |
594 | pub fn parse_template(template_text: &str) -> TemplateParseResult<ExpressionNode> {
    |                                      ^^^^                         -------------- the lifetime gets resolved as `'_`
    |                                      |
    |                                      this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
594 | pub fn parse_template(template_text: &str) -> TemplateParseResult<ExpressionNode<'_>> {
    |                                                                                 ++++

warning: `jj-cli` (lib) generated 9 warnings (run `cargo clippy --fix --lib -p jj-cli` to apply 9 suggestions)
       Fixed lib/testutils/src/test_backend.rs (0 fixes)
warning: `testutils` (lib) generated 1 warning (1 duplicate)
       Fixed cli/examples/custom-backend/main.rs (0 fixes)
warning: lifetime flowing from input to output with different syntax can be confusing
   --> cli/examples/custom-backend/main.rs:217:9
    |
217 |         &self,
    |         ^^^^^ this lifetime flows to the output
...
221 |     ) -> BackendResult<BoxStream<BackendResult<CopyRecord>>> {
    |                        ------------------------------------ the lifetime gets resolved as `'_`
    |
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
221 |     ) -> BackendResult<BoxStream<'_, BackendResult<CopyRecord>>> {
    |                                  +++

warning: `jj-cli` (example "custom-backend") generated 1 warning (run `cargo clippy --fix --example "custom-backend"` to apply 1 suggestion)
       Fixed lib/src/default_index/readonly.rs (0 fixes)
       Fixed lib/src/tree.rs (0 fixes)
       Fixed lib/src/secret_backend.rs (0 fixes)
       Fixed lib/src/backend.rs (0 fixes)
       Fixed lib/src/store.rs (0 fixes)
       Fixed lib/src/git_backend.rs (0 fixes)
       Fixed lib/src/merged_tree.rs (0 fixes)
       Fixed lib/src/fileset_parser.rs (0 fixes)
       Fixed lib/src/config.rs (0 fixes)
       Fixed lib/src/repo.rs (0 fixes)
       Fixed lib/src/workspace.rs (0 fixes)
       Fixed lib/src/revset_parser.rs (0 fixes)
       Fixed lib/src/simple_backend.rs (0 fixes)
warning: lifetime flowing from input to output with different syntax can be confusing
   --> lib/src/fileset_parser.rs:356:30
    |
356 |     fn parse_into_kind(text: &str) -> Result<ExpressionKind, FilesetParseErrorKind> {
    |                              ^^^^            -------------- the lifetime gets resolved as `'_`
    |                              |
    |                              this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
356 |     fn parse_into_kind(text: &str) -> Result<ExpressionKind<'_>, FilesetParseErrorKind> {
    |                                                            ++++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> lib/src/fileset_parser.rs:362:41
    |
362 |     fn parse_maybe_bare_into_kind(text: &str) -> Result<ExpressionKind, FilesetParseErrorKind> {
    |                                         ^^^^            -------------- the lifetime gets resolved as `'_`
    |                                         |
    |                                         this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
362 |     fn parse_maybe_bare_into_kind(text: &str) -> Result<ExpressionKind<'_>, FilesetParseErrorKind> {
    |                                                                       ++++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> lib/src/fileset_parser.rs:368:31
    |
368 |     fn parse_normalized(text: &str) -> ExpressionNode {
    |                               ^^^^     -------------- the lifetime gets resolved as `'_`
    |                               |
    |                               this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
368 |     fn parse_normalized(text: &str) -> ExpressionNode<'_> {
    |                                                      ++++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> lib/src/fileset_parser.rs:372:42
    |
372 |     fn parse_maybe_bare_normalized(text: &str) -> ExpressionNode {
    |                                          ^^^^     -------------- the lifetime gets resolved as `'_`
    |                                          |
    |                                          this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
372 |     fn parse_maybe_bare_normalized(text: &str) -> ExpressionNode<'_> {
    |                                                                 ++++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> lib/src/revset_parser.rs:888:30
    |
888 |     fn parse_into_kind(text: &str) -> Result<ExpressionKind, RevsetParseErrorKind> {
    |                              ^^^^            -------------- the lifetime gets resolved as `'_`
    |                              |
    |                              this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
888 |     fn parse_into_kind(text: &str) -> Result<ExpressionKind<'_>, RevsetParseErrorKind> {
    |                                                            ++++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> lib/src/revset_parser.rs:894:31
    |
894 |     fn parse_normalized(text: &str) -> ExpressionNode {
    |                               ^^^^     -------------- the lifetime gets resolved as `'_`
    |                               |
    |                               this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
894 |     fn parse_normalized(text: &str) -> ExpressionNode<'_> {
    |                                                      ++++

warning: `jj-lib` (lib test) generated 23 warnings (17 duplicates) (run `cargo clippy --fix --lib -p jj-lib --tests` to apply 6 suggestions)
       Fixed cli/src/config.rs (0 fixes)
       Fixed cli/src/cli_util.rs (0 fixes)
       Fixed cli/src/template_parser.rs (0 fixes)
warning: lifetime flowing from input to output with different syntax can be confusing
   --> cli/src/template_parser.rs:776:39
    |
776 |     fn parse_into_kind(template_text: &str) -> Result<ExpressionKind, TemplateParseErrorKind> {
    |                                       ^^^^            -------------- the lifetime gets resolved as `'_`
    |                                       |
    |                                       this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
776 |     fn parse_into_kind(template_text: &str) -> Result<ExpressionKind<'_>, TemplateParseErrorKind> {
    |                                                                     ++++

warning: lifetime flowing from input to output with different syntax can be confusing
   --> cli/src/template_parser.rs:782:40
    |
782 |     fn parse_normalized(template_text: &str) -> ExpressionNode {
    |                                        ^^^^     -------------- the lifetime gets resolved as `'_`
    |                                        |
    |                                        this lifetime flows to the output
    |
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
    |
782 |     fn parse_normalized(template_text: &str) -> ExpressionNode<'_> {
    |                                                               ++++

warning: `jj-cli` (lib test) generated 11 warnings (9 duplicates) (run `cargo clippy --fix --lib -p jj-cli --tests` to apply 2 suggestions)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 56.59s

Reproducer

See above.

I just updated the nightly from rustc 1.89.0-nightly (4b27a04cc 2025-06-04) to today's nightly (see below).

I double-checked, and this was not a problem with rustc 1.89.0-nightly (59aa1e873 2025-06-03). These warnings are not generated at all with that version from a week ago (some unrelated cloned_refs_to_sliced_ref warnings are).

Version
rustc 1.89.0-nightly (d13a431a6 2025-06-09)
binary: rustc
commit-hash: d13a431a6cc69cd65efe7c3eb7808251d6fd7a46
commit-date: 2025-06-09
host: aarch64-apple-darwin
release: 1.89.0-nightly
LLVM version: 20.1.5
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.

Research direction

Reproduce the report at the referenced repository revision using the listed cargo clippy --fix commands, focusing on the mismatched_lifetime_syntaxes warnings. Compare Clippy's reported fixes with the affected paths, including lib/testutils/src/test_backend.rs, cli/src/cli_util.rs, and cli/examples/custom-backend/main.rs. Done means clippy --fix applies its suggestions and does not recommend rerunning the same command.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.