rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.46k stars 1.54k forks source link

SIGSEGV applying clippy fixes #9942

Closed matthiaskrgr closed 1 year ago

matthiaskrgr commented 1 year ago

Summary

// check-pass

mod x {
    pub use crate::y::*;
    pub use std::ops::Deref as _;
}

mod y {
    pub use crate::x::*;
    pub use std::ops::Deref as _;
}

pub fn main() {
    use x::*;
    (&0).deref();
}

If I process this code with cargo -vvvvvv clippy --fix -- -Wclippy::wildcard_imports I get some weird invalid memory reference crash but I can't see any compiler stacktrace unfortunately :(

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

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

  * src/main.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/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 identifier, found reserved identifier `_`
  --> src/main.rs:14:12
   |
14 |     use x::_;
   |            ^ expected identifier, found reserved identifier

rustc exited abnormally: signal: 11, SIGSEGV: invalid memory reference
Original diagnostics will follow.

warning: usage of wildcard import
  --> src/main.rs:14:9
   |
14 |     use x::*;
   |         ^^^^ help: try: `x::_`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports
   = note: requested on the command line with `-W clippy::wildcard-imports`

warning: crate `F` should have a snake case name
  |
  = help: convert the identifier to snake case: `f`
  = note: `#[warn(non_snake_case)]` on by default

warning: unused return value of `std::ops::Deref::deref` that must be used
  --> src/main.rs:15:5
   |
15 |     (&0).deref();
   |     ^^^^^^^^^^^^
   |
   = note: `#[warn(unused_must_use)]` on by default

warning: `F` (bin "F") generated 3 warnings (run `cargo fix --bin "F"` to apply 1 suggestion)
warning: `F` (bin "F" test) generated 3 warnings (3 duplicates)
    Finished dev [unoptimized + debuginfo] target(s) in 0.18s

Version

rustc 1.67.0-nightly (70f8737b2 2022-11-23)
binary: rustc
commit-hash: 70f8737b2f5d3bf7d6b784fad00b663b7ff9feda
commit-date: 2022-11-23
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

Error output

No response

smoelius commented 1 year ago

@matthiaskrgr Are you fuzzing Clippy? Is your approach described somewhere?

matthiaskrgr commented 1 year ago

Im running clippy --fix on all sorts of rust files and check if the suggestion applies. :)

https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/moar.20lint.20checking