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.34k stars 1.53k forks source link

`Cargo clippy --fix` introduces compilation errors on `rustc 1.79.0-nightly` #12565

Open PanieriLorenzo opened 6 months ago

PanieriLorenzo commented 6 months ago

Summary

Got this message from clippy from running cargo clippy --fix on nightly.

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

  * stoej-dsp-graph/src/combinators.rs
  * stoej-dsp-graph/src/combinators/filter.rs
  * stoej-dsp-graph/src/lib.rs
  * stoej-dsp-graph/src/macros.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[E0433]: failed to resolve: there are too many leading `super` keywords
  --> stoej-dsp-graph/src/combinators.rs:52:25
   |
52 |         self.map(super::super::api::FloatOps::abs)
   |                         ^^^^^ there are too many leading `super` keywords
   |
help: consider importing this trait
   |
1  + use crate::api::FloatOps;
   |
help: if you import `FloatOps`, refer to it directly
   |
52 -         self.map(super::super::api::FloatOps::abs)
52 +         self.map(FloatOps::abs)
   |

error[E0433]: failed to resolve: there are too many leading `super` keywords
  --> stoej-dsp-graph/src/combinators.rs:56:25
   |
56 |         self.map(super::super::api::FloatOps::exp)
   |                         ^^^^^ there are too many leading `super` keywords
   |
help: consider importing this trait
   |
1  + use crate::api::FloatOps;
   |
help: if you import `FloatOps`, refer to it directly
   |
56 -         self.map(super::super::api::FloatOps::exp)
56 +         self.map(FloatOps::exp)
   |

warning: unused import: `FloatOps`
  --> stoej-dsp-graph/src/combinators.rs:11:17
   |
11 |     api::{Data, FloatOps, Processor},
   |                 ^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: binding's name is too similar to existing binding
   --> stoej-dsp-graph/src/combinators.rs:514:17
    |
514 |         let mut baz = t.lerp(foo, bar);
    |                 ^^^
    |
note: existing binding defined here
   --> stoej-dsp-graph/src/combinators.rs:512:13
    |
512 |         let bar = constant(f32x4::from_array([10.0, 20.0, 30.0, 40.0]));
    |             ^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#similar_names
note: the lint level is defined here
   --> stoej-dsp-graph/src/lib.rs:2:9
    |
2   | #![warn(clippy::pedantic)]
    |         ^^^^^^^^^^^^^^^^
    = note: `#[warn(clippy::similar_names)]` implied by `#[warn(clippy::pedantic)]`

warning: unused macro definition: `forward`
 --> stoej-dsp-graph/src/macros.rs:4:14
  |
4 | macro_rules! forward {
  |              ^^^^^^^
  |
  = note: `#[warn(unused_macros)]` on by default

warning: use of deprecated associated function `mem::Bus::<F>::new_old`
   --> stoej-dsp-graph/src/combinators.rs:118:24
    |
118 |         let fbk = Bus::new_old();
    |                        ^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: use of deprecated associated function `mem::Bus::<F>::new_old`
  --> stoej-dsp-graph/src/combinators/filter.rs:24:25
   |
24 |         let y_z1 = Bus::new_old();
   |                         ^^^^^^^

warning: use of deprecated associated function `mem::Bus::<F>::new_old`
   --> stoej-dsp-graph/src/combinators.rs:147:32
    |
147 |         let bus = Rc::new(Bus::new_old());
    |                                ^^^^^^^

warning: use of deprecated associated function `mem::Bus::<F>::new_old`
   --> stoej-dsp-graph/src/combinators.rs:495:24
    |
495 |         let foo = Bus::new_old();
    |                        ^^^^^^^

warning: use of deprecated associated function `mem::Bus::<F>::new_old`
  --> stoej-dsp-graph/src/lib.rs:77:24
   |
77 |         let fbk = Bus::new_old();
   |                        ^^^^^^^

error: aborting due to 2 previous errors; 8 warnings emitted

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

warning: binding's name is too similar to existing binding
   --> stoej-dsp-graph/src/combinators.rs:514:17
    |
514 |         let mut baz = t.lerp(foo, bar);
    |                 ^^^
    |
note: existing binding defined here
   --> stoej-dsp-graph/src/combinators.rs:512:13
    |
512 |         let bar = constant(f32x4::from_array([10.0, 20.0, 30.0, 40.0]));
    |             ^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#similar_names
note: the lint level is defined here
   --> stoej-dsp-graph/src/lib.rs:2:9
    |
2   | #![warn(clippy::pedantic)]
    |         ^^^^^^^^^^^^^^^^
    = note: `#[warn(clippy::similar_names)]` implied by `#[warn(clippy::pedantic)]`

warning: use of deprecated associated function `mem::Bus::<F>::new_old`
   --> stoej-dsp-graph/src/combinators.rs:495:24
    |
495 |         let foo = Bus::new_old();
    |                        ^^^^^^^

warning: use of deprecated associated function `mem::Bus::<F>::new_old`
  --> stoej-dsp-graph/src/lib.rs:77:24
   |
77 |         let fbk = Bus::new_old();
   |                        ^^^^^^^

warning: missing `#[must_use]` attribute on a method returning `Self`
  --> stoej-dsp-graph/src/api.rs:28:5
   |
28 |     fn abs(self) -> Self;
   |     ^^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider adding the `#[must_use]` attribute to the method or directly to the `Self` type
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#return_self_not_must_use
   = note: `#[warn(clippy::return_self_not_must_use)]` implied by `#[warn(clippy::pedantic)]`

warning: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
   --> stoej-dsp-graph/src/combinators.rs:481:45
    |
481 |             assert_eq!(counter.next(), Some(i as f32));
    |                                             ^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_precision_loss
    = note: `#[warn(clippy::cast_precision_loss)]` implied by `#[warn(clippy::pedantic)]`

warning: consider adding a `;` to the last statement for consistent formatting
   --> stoej-dsp-graph/src/combinators.rs:505:13
    |
505 |             assert_eq!(i, j as usize)
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `assert_eq!(i, j as usize);`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    = note: `#[warn(clippy::semicolon_if_nothing_returned)]` implied by `#[warn(clippy::pedantic)]`

warning: casting `f32` to `usize` may truncate the value
   --> stoej-dsp-graph/src/combinators.rs:505:27
    |
505 |             assert_eq!(i, j as usize)
    |                           ^^^^^^^^^^
    |
    = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation
    = note: `#[warn(clippy::cast_possible_truncation)]` implied by `#[warn(clippy::pedantic)]`

warning: casting `f32` to `usize` may lose the sign of the value
   --> stoej-dsp-graph/src/combinators.rs:505:27
    |
505 |             assert_eq!(i, j as usize)
    |                           ^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_sign_loss
    = note: `#[warn(clippy::cast_sign_loss)]` implied by `#[warn(clippy::pedantic)]`

warning: consider adding a `;` to the last statement for consistent formatting
   --> stoej-dsp-graph/src/mem.rs:174:9
    |
174 |         self.mem.set(sr)
    |         ^^^^^^^^^^^^^^^^ help: add a `;` here: `self.mem.set(sr);`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

warning: strict comparison of `f32` or `f64`
   --> stoej-dsp-graph/src/mem.rs:270:9
    |
270 |         assert_eq!(rx.receive().unwrap(), 0.0);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
    = note: `#[warn(clippy::float_cmp)]` implied by `#[warn(clippy::pedantic)]`
    = note: this warning originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `stoej-dsp-graph` (lib test) generated 62 warnings (52 duplicates) (run `cargo clippy --fix --lib -p stoej-dsp-graph --tests` to apply 2 suggestions)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 12.15s

Reproducer

Grab this commit from affected repository: permalink

Navigate to sub-crate stoej-dsp-graph

Run cargo clippy --fix

Version

rustc 1.79.0-nightly (5f2c7d2bf 2024-03-25)
binary: rustc
commit-hash: 5f2c7d2bfd46cad00352ab7cd66242077e2e518c
commit-date: 2024-03-25
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Additional Labels

@rustbot label +I-suggestion-causes-error

modelflat commented 6 months ago

This seems to be related to the changes I made some time ago: #11370

However, the doc page for super on Nightly haven't been updated yet and states that super can be chained; could this be a rustc bug?

In the scope of clippy the easiest fix is to update max_super to 1 here.