Skip to content

clippy failed to automatically apply fixes suggested by rustc #15063

Open
@z-jxy

Description

@z-jxy

Summary

When trying to run clippy --fix it reported:

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

  * src/objects/aiaca.rs
  * src/objects/enterpriseca.rs
  * src/objects/group.rs
  * src/objects/rootca.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

Specifically, it failed to apply these changes

1

this:

 if &ext.oid == &oid!(2.5.29 .19)

should've changed to this:

 if ext.oid == oid!(2.5.29 .19)

instead, we got this:

if ext.oid == $crate::Oid::new($crate::exports::borrow::Cow::Borrowed( &$crate::oid!(raw $( $item ).*), ))

2

this:

else if sid.ends_with("S-1-5-32-544") 
    || sid.ends_with("S-1-5-32-548") 
    || sid.ends_with("S-1-5-32-549")
    || sid.ends_with("S-1-5-32-550") 
    || sid.ends_with("S-1-5-32-551") 
    {
        self.properties.highvalue = true;
    }

should've been this:

else {
    self.properties.highvalue = sid.ends_with("S-1-5-32-544")
        || sid.ends_with("S-1-5-32-548")
        || sid.ends_with("S-1-5-32-549")
        || sid.ends_with("S-1-5-32-550")
        || sid.ends_with("S-1-5-32-551")
}

instead we got this (braces missing):

else self.properties.highvalue = sid.ends_with("S-1-5-32-544")
        || sid.ends_with("S-1-5-32-548")
        || sid.ends_with("S-1-5-32-549")
        || sid.ends_with("S-1-5-32-550")
        || sid.ends_with("S-1-5-32-551")

Full output:

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

  * src/objects/aiaca.rs
  * src/objects/enterpriseca.rs
  * src/objects/group.rs
  * src/objects/rootca.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: expected `{`, found keyword `self`
   --> src/objects/group.rs:150:26
    |
150 |                     else self.properties.highvalue = sid.ends_with("S-1-5-32-544") 
    |                          ^^^^ expected `{`
    |
help: you might have meant to write this as part of a block
    |
150 ~                     else { self.properties.highvalue = sid.ends_with("S-1-5-32-544") 
151 |                     || sid.ends_with("S-1-5-32-548") 
152 |                     || sid.ends_with("S-1-5-32-549")
153 ~                     || sid.ends_with("S-1-5-32-550") || sid.ends_with("S-1-5-32-551") };
    |

error: expected `{`, found keyword `self`
   --> src/objects/group.rs:190:26
    |
190 |                     else self.properties.highvalue = sid.ends_with("S-1-5-32-544") 
    |                          ^^^^ expected `{`
    |
help: you might have meant to write this as part of a block
    |
190 ~                     else { self.properties.highvalue = sid.ends_with("S-1-5-32-544") 
191 |                     || sid.ends_with("S-1-5-32-548") 
192 |                     || sid.ends_with("S-1-5-32-549")
193 ~                     || sid.ends_with("S-1-5-32-550") || sid.ends_with("S-1-5-32-551") };
    |

error: expected expression, found `$`
   --> src/objects/aiaca.rs:140:47
    |
140 | ...                   if ext.oid == $crate::Oid::new($crate::exports::borrow::Cow::Borrowed(
    |                                     ^ expected expression

error: expected expression, found `$`
   --> src/objects/rootca.rs:135:47
    |
135 | ...                   if ext.oid == $crate::Oid::new($crate::exports::borrow::Cow::Borrowed(
    |                                     ^ expected expression

error: expected expression, found `$`
   --> src/objects/enterpriseca.rs:204:47
    |
204 | ...                   if ext.oid == $crate::Oid::new($crate::exports::borrow::Cow::Borrowed(
    |                                     ^ expected expression

warning: unused import: `x509_parser::oid_registry::asn1_rs::oid`
 --> src/objects/aiaca.rs:3:5
  |
3 | use x509_parser::oid_registry::asn1_rs::oid;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `x509_parser::oid_registry::asn1_rs::oid`
 --> src/objects/rootca.rs:3:5
  |
3 | use x509_parser::oid_registry::asn1_rs::oid;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `x509_parser::oid_registry::asn1_rs::oid`
 --> src/objects/enterpriseca.rs:4:5
  |
4 | use x509_parser::oid_registry::asn1_rs::oid;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 5 previous errors; 3 warnings emitted

Original diagnostics will follow.

Reproducer

I tried this code:

git clone https://github.com/g0h4n/RustHound-CE
cd RustHound-CE
cargo clippy --features nogssapi --no-default-features --fix

I expected to see this happen:

Clippy fixes most warnings and produces code that compiles

Instead, this happened:

Clippy produced code that does not compile

Version

rustc 1.88.0-nightly (b4c8b0c3f 2025-04-25)
binary: rustc
commit-hash: b4c8b0c3f0533bb342a4873ff59bdad3883ab8e3
commit-date: 2025-04-25
host: aarch64-apple-darwin
release: 1.88.0-nightly
LLVM version: 20.1.2

Additional Labels

No response

Metadata

Metadata

Assignees

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