Clippy returning incorrect exit code when automatically applying lint suggestions

I'm running Clippy with the following command:

cargo clippy --fix -- -F warnings

It runs, returns the output below, and terminates with the exit code 0:

warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
  --> project-euler/multiples_of_3_or_5/src/main.rs:46:37
   |
46 | pub fn sum_multiples(multiplicands: &Vec<u32>, maximum_possible_multiple: u32) -> u32 {
   |                                     ^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
   = note: `-F clippy::ptr-arg` implied by `-F warnings`
help: change this to
   |
46 ~ pub fn sum_multiples(multiplicands: &[u32], maximum_possible_multiple: u32) -> u32 {
47 |     let possible_multiples: std::ops::Range<u32> = 1..maximum_possible_multiple;
 ...
50 |         .filter(|possible_multiple| {
51 ~             multiplicands.to_owned()
   |

warning: called `is_some()` after searching an `Iterator` with `find`
  --> project-euler/multiples_of_3_or_5/src/main.rs:54:18
   |
54 |                   .find(|multiplicand| possible_multiple.is_multiple_of(*multiplicand))
   |  __________________^
55 | |                 .is_some()
   | |__________________________^ help: use `any()` instead: `any(|multiplicand| possible_multiple.is_multiple_of(multiplicand))`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
   = note: `-F clippy::search-is-some` implied by `-F warnings`

warning: `multiples_of_3_or_5` (bin "multiples_of_3_or_5") generated 2 warnings
warning: `multiples_of_3_or_5` (bin "multiples_of_3_or_5" test) generated 2 warnings (2 duplicates)
    Finished dev [unoptimized + debuginfo] target(s) in 1.49s

But whenever i repeat the same command, but without the --fix flag, works as expected, the output is similar to the one above but slightly different, it terminates with the exit code 101:

error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
  --> project-euler/multiples_of_3_or_5/src/main.rs:46:37
   |
46 | pub fn sum_multiples(multiplicands: &Vec<u32>, maximum_possible_multiple: u32) -> u32 {
   |                                     ^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
   = note: `-F clippy::ptr-arg` implied by `-F warnings`
help: change this to
   |
46 ~ pub fn sum_multiples(multiplicands: &[u32], maximum_possible_multiple: u32) -> u32 {
47 |     let possible_multiples: std::ops::Range<u32> = 1..maximum_possible_multiple;
 ...
50 |         .filter(|possible_multiple| {
51 ~             multiplicands.to_owned()
   |

error: called `is_some()` after searching an `Iterator` with `find`
  --> project-euler/multiples_of_3_or_5/src/main.rs:54:18
   |
54 |                   .find(|multiplicand| possible_multiple.is_multiple_of(*multiplicand))
   |  __________________^
55 | |                 .is_some()
   | |__________________________^ help: use `any()` instead: `any(|multiplicand| possible_multiple.is_multiple_of(multiplicand))`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
   = note: `-F clippy::search-is-some` implied by `-F warnings`

error: could not compile `multiples_of_3_or_5` (bin "multiples_of_3_or_5") due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

Cross-posted at: rust - Clippy returning incorrect exit code when automatically applying lint suggestions - Stack Overflow

Clippy doesn't have auto-fix ability for all warnings. Sometimes it's intentional, because the warning is a guess which may not be correct, sometimes just nobody wrote the necessary fix code yet.

I'm not sure if it's a bug. The 0 return code could mean it applied all the fixes that it could.

That's one way to view things, one might argue that something like this is opinion-based, but i strongly believe that when you pass flags like --deny or even --forbid, those should be prioritized, because if something of such criticality is caught by clippy, ideally, it shouldn't be allowed into the codebase, be it on a CI pipeline or on a Git hook

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.