Skip to content

Clippy fails to automatically fix issues for serde-json-core #14157

Open
@sirhcel

Description

@sirhcel

Summary

Clippy asked me to report this following when I tried to automatically fix issues for https://github.com/sirhcel/serde-json-core/commits/147cac1064c7ed65c04b48297067f742acd5f504/.

$ cargo clippy --fix
    Checking serde-json-core v0.6.0 (/[...]/serde-json-core)
warning: error applying suggestions to `src/de/enum_.rs`

The full error message was:

> cannot replace slice of data that was already replaced

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

warning: error applying suggestions to `src/de/enum_.rs`

The full error message was:

> cannot replace slice of data that was already replaced

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

warning: error applying suggestions to `src/de/map.rs`

The full error message was:

> cannot replace slice of data that was already replaced

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

       Fixed src/de/enum_.rs (0 fixes)
       Fixed src/de/map.rs (0 fixes)
warning: the following explicit lifetimes could be elided: 'a, 's
  --> src/de/enum_.rs:28:11
   |
28 | impl<'de, 'a, 's> de::VariantAccess<'de> for UnitVariantAccess<'a, 'de, 's> {
   |           ^^  ^^                                               ^^       ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
note: the lint level is defined here
  --> src/lib.rs:79:9
   |
79 | #![deny(warnings)]
   |         ^^^^^^^^
   = note: `#[warn(clippy::needless_lifetimes)]` implied by `#[warn(warnings)]`
help: elide the lifetimes
   |
28 - impl<'de, 'a, 's> de::VariantAccess<'de> for UnitVariantAccess<'a, 'de, 's> {
28 + impl<'de, > de::VariantAccess<'de> for UnitVariantAccess<'_, 'de, '_> {
   |

warning: the following explicit lifetimes could be elided: 'a, 's
  --> src/de/enum_.rs:81:11
   |
81 | impl<'de, 'a, 's> de::VariantAccess<'de> for VariantAccess<'a, 'de, 's> {
   |           ^^  ^^                                           ^^       ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
   |
81 - impl<'de, 'a, 's> de::VariantAccess<'de> for VariantAccess<'a, 'de, 's> {
81 + impl<'de, > de::VariantAccess<'de> for VariantAccess<'_, 'de, '_> {
   |

warning: the following explicit lifetimes could be elided: 'a, 's
  --> src/de/map.rs:64:11
   |
64 | impl<'de, 'a, 's> de::Deserializer<'de> for MapKey<'a, 'de, 's> {
   |           ^^  ^^                                   ^^       ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
   |
64 - impl<'de, 'a, 's> de::Deserializer<'de> for MapKey<'a, 'de, 's> {
64 + impl<'de, > de::Deserializer<'de> for MapKey<'_, 'de, '_> {
   |

warning: `serde-json-core` (lib) generated 3 warnings (run `cargo clippy --fix --lib -p serde-json-core` to apply 3 suggestions)
warning: error applying suggestions to `src/de/map.rs`

The full error message was:

> cannot replace slice of data that was already replaced

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

warning: error applying suggestions to `src/de/enum_.rs`

The full error message was:

> cannot replace slice of data that was already replaced

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

warning: error applying suggestions to `src/de/enum_.rs`

The full error message was:

> cannot replace slice of data that was already replaced

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

       Fixed src/de/map.rs (0 fixes)
       Fixed src/de/enum_.rs (0 fixes)
warning: `serde-json-core` (lib test) generated 3 warnings (3 duplicates)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.41s

Reproducer

I tried this code: https://github.com/sirhcel/serde-json-core/commits/147cac1064c7ed65c04b48297067f742acd5f504/

I expected to see this happen: Clippy to fix all issues it reported from cargo clippy --fix.

Instead, this happened: I got warnings asking me to open an issue.

Version

rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.84.0
LLVM version: 19.1.5

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions