Skip to content

ICE when invoking cargo clippy --fix #12784

Closed
rust-lang/rust
#124926
@Zoybean

Description

@Zoybean

Summary

I encountered an ICE when invoking cargo clippy --fix

Version

rustc 1.80.0-nightly (87293c958 2024-05-08)
binary: rustc
commit-hash: 87293c9585a7fb2cc83ca9949ae79661d5d3c31a
commit-date: 2024-05-08
host: x86_64-pc-windows-msvc
release: 1.80.0-nightly
LLVM version: 18.1.4

Error output

Backtrace

  warning: failed to automatically apply fixes suggested by rustc to crate `work_log`

after fixes were automatically applied the compiler reported errors within these files:

* src\lib.rs

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

The following errors were reported:
error[E0034]: multiple applicable items in scope
  --> src\lib.rs:1450:18
   |
1450 |                 .intersperse(", ")
   |                  ^^^^^^^^^^^ multiple `intersperse` found
   |
   = note: candidate #1 is defined in an impl of the trait `itertools::Itertools` for the type `T`
   = note: candidate #2 is defined in an impl of the trait `std::iter::Iterator` for the type `std::collections::hash_set::IntoIter<K>`
help: disambiguate the method for candidate #1
   |
1448 ~             let comments = itertools::Itertools::intersperse(nub_comments(vec.iter().map(|(_, p)| &*p.comment))
1449 +                 .into_iter(), ", ")
   |
help: disambiguate the method for candidate #2
   |
1448 ~             let comments = std::iter::Iterator::intersperse(nub_comments(vec.iter().map(|(_, p)| &*p.comment))
1449 +                 .into_iter(), ", ")
   |

error[E0034]: multiple applicable items in scope
  --> src\lib.rs:1488:18
   |
1488 |                 .intersperse("\n")
   |                  ^^^^^^^^^^^ multiple `intersperse` found
   |
   = note: candidate #1 is defined in an impl of the trait `itertools::Itertools` for the type `T`
   = note: candidate #2 is defined in an impl of the trait `std::iter::Iterator` for the type `std::collections::hash_set::IntoIter<K>`
help: disambiguate the method for candidate #1
   |
1486 ~             let comments: String = itertools::Itertools::intersperse(nub_comments(vec.iter().map(|(_, j)| &*j.comment))
1487 +                 .into_iter(), "\n")
   |
help: disambiguate the method for candidate #2
   |
1486 ~             let comments: String = std::iter::Iterator::intersperse(nub_comments(vec.iter().map(|(_, j)| &*j.comment))
1487 +                 .into_iter(), "\n")
   |

warning: unused import: `io::Write`
--> src\lib.rs:10:33
 |
10 | use std::{collections::HashSet, io::Write, iter::Sum, mem};
 |                                 ^^^^^^^^^
 |
 = note: `#[warn(unused_imports)]` on by default

error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0034`.
Original diagnostics will follow.

warning: unused import: `info`
--> src\io.rs:7:25
|
7 | use log::{debug, error, info};
|                         ^^^^
|
= note: `#[warn(unused_imports)]` on by default

warning: a method with this name may be added to the standard library in the future
  --> src\lib.rs:1449:18
   |
1449 |                 .intersperse(", ")
   |                  ^^^^^^^^^^^
   |
   = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
   = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
   = help: call with fully qualified syntax `itertools::Itertools::intersperse(...)` to keep using the current method
   = note: `#[warn(unstable_name_collisions)]` on by default
help: add `#![feature(iter_intersperse)]` to the crate attributes to enable `std::iter::Iterator::intersperse`
   |
2    + #![feature(iter_intersperse)]
   |

warning: a method with this name may be added to the standard library in the future
  --> src\lib.rs:1487:18
   |
1487 |                 .intersperse("\n")
   |                  ^^^^^^^^^^^
   |
   = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
   = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
   = help: call with fully qualified syntax `itertools::Itertools::intersperse(...)` to keep using the current method
help: add `#![feature(iter_intersperse)]` to the crate attributes to enable `std::iter::Iterator::intersperse`
   |
2    + #![feature(iter_intersperse)]
   |

warning: unused import: `io::Write`
--> src\lib.rs:9:33
|
9 | use std::{collections::HashSet, io::Write, iter::Sum, mem};
|                                 ^^^^^^^^^

warning: method `archive_all` is never used
  --> src\lib.rs:1116:8
   |
762  | impl Log {
   | -------- method in this implementation
...
1116 |     fn archive_all(&mut self) {
   |        ^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: function `with_index` is never used
  --> src\lib.rs:1626:4
   |
1626 | fn with_index<T, R>(mut f: impl FnMut(usize, &T) -> R) -> impl FnMut(&T) -> R {
   |    ^^^^^^^^^^

warning: method `retain_indices` is never used
  --> src\lib.rs:1632:8
   |
1631 | trait VecExt<T> {
   |       ------ method in this trait
1632 |     fn retain_indices(&mut self, indices: &[usize]);
   |        ^^^^^^^^^^^^^^

warning: function cannot return without recursing
 --> src\hours.rs:169:5
  |
169 | /     fn from(hours: Hours) -> Self {
170 | |         hours.into()
171 | |     }
  | |_____^
  |
note: recursive call site
 --> src\hours.rs:170:9
  |
170 |         hours.into()
  |         ^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unconditional_recursion
  = note: `#[warn(clippy::unconditional_recursion)]` on by default

warning: this pattern takes a reference on something that is being dereferenced
  --> src\lib.rs:1070:25
   |
1070 |                 .map(|&(&ref a, ref b)| (a, b))
   |                         ^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
   = note: `#[warn(clippy::needless_borrowed_reference)]` on by default
help: try removing the `&ref` part
   |
1070 -                 .map(|&(&ref a, ref b)| (a, b))
1070 +                 .map(|&(a, ref b)| (a, b))
   |

warning: `work-log` (lib) generated 9 warnings (run `cargo clippy --fix --lib -p work-log` to apply 4 suggestions)
warning: failed to automatically apply fixes suggested by rustc to crate `work_log`

after fixes were automatically applied the compiler reported errors within these files:

* src\lib.rs

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

The following errors were reported:
error[E0034]: multiple applicable items in scope
  --> src\lib.rs:1450:18
   |
1450 |                 .intersperse(", ")
   |                  ^^^^^^^^^^^ multiple `intersperse` found
   |
   = note: candidate #1 is defined in an impl of the trait `itertools::Itertools` for the type `T`
   = note: candidate #2 is defined in an impl of the trait `std::iter::Iterator` for the type `std::collections::hash_set::IntoIter<K>`
help: disambiguate the method for candidate #1
   |
1448 ~             let comments = itertools::Itertools::intersperse(nub_comments(vec.iter().map(|(_, p)| &*p.comment))
1449 +                 .into_iter(), ", ")
   |
help: disambiguate the method for candidate #2
   |
1448 ~             let comments = std::iter::Iterator::intersperse(nub_comments(vec.iter().map(|(_, p)| &*p.comment))
1449 +                 .into_iter(), ", ")
   |

error[E0034]: multiple applicable items in scope
  --> src\lib.rs:1488:18
   |
1488 |                 .intersperse("\n")
   |                  ^^^^^^^^^^^ multiple `intersperse` found
   |
   = note: candidate #1 is defined in an impl of the trait `itertools::Itertools` for the type `T`
   = note: candidate #2 is defined in an impl of the trait `std::iter::Iterator` for the type `std::collections::hash_set::IntoIter<K>`
help: disambiguate the method for candidate #1
   |
1486 ~             let comments: String = itertools::Itertools::intersperse(nub_comments(vec.iter().map(|(_, j)| &*j.comment))
1487 +                 .into_iter(), "\n")
   |
help: disambiguate the method for candidate #2
   |
1486 ~             let comments: String = std::iter::Iterator::intersperse(nub_comments(vec.iter().map(|(_, j)| &*j.comment))
1487 +                 .into_iter(), "\n")
   |

warning: unused import: `io::Write`
--> src\lib.rs:10:33
 |
10 | use std::{collections::HashSet, io::Write, iter::Sum, mem};
 |                                 ^^^^^^^^^
 |
 = note: `#[warn(unused_imports)]` on by default

error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0034`.
Original diagnostics will follow.

warning: `work-log` (lib test) generated 9 warnings (9 duplicates)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions