Skip to content

Remove redundant let bindings #16

Remove redundant let bindings

Remove redundant let bindings #16

GitHub Actions / clippy succeeded Nov 26, 2024 in 1s

clippy

53 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 53
Note 0
Help 0

Versions

  • rustc 1.82.0 (f6e511eec 2024-10-15)
  • cargo 1.82.0 (8f40fc59f 2024-08-21)
  • clippy 0.1.82 (f6e511e 2024-10-15)

Annotations

Check warning on line 71 in sdl-gui/src/gui.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

casting to the same type is unnecessary (`usize` -> `usize`)

warning: casting to the same type is unnecessary (`usize` -> `usize`)
  --> sdl-gui/src/gui.rs:71:25
   |
71 |                 let i = (y * 160 + x) as usize;
   |                         ^^^^^^^^^^^^^^^^^^^^^^ help: try: `(y * 160 + x)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
   = note: `#[warn(clippy::unnecessary_cast)]` on by default

Check warning on line 151 in libretro/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded unit expression

warning: unneeded unit expression
   --> libretro/src/lib.rs:151:9
    |
151 |         ()
    |         ^^ help: remove the final `()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
    = note: `#[warn(clippy::unused_unit)]` on by default

Check warning on line 88 in wasm-gui/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7)
  --> wasm-gui/src/lib.rs:79:1
   |
79 | / pub fn set_control_state(
80 | |     a: bool,
81 | |     b: bool,
82 | |     up: bool,
...  |
87 | |     select: bool,
88 | | ) {
   | |_^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
   = note: `#[warn(clippy::too_many_arguments)]` on by default

Check warning on line 68 in wasm-gui/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

the loop variable `i` is only used to index `frame`

warning: the loop variable `i` is only used to index `frame`
  --> wasm-gui/src/lib.rs:68:14
   |
68 |     for i in 0..SCREEN_BUFFER_SIZE {
   |              ^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
   = note: `#[warn(clippy::needless_range_loop)]` on by default
help: consider using an iterator
   |
68 |     for <item> in frame.iter().take(SCREEN_BUFFER_SIZE) {
   |         ~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check warning on line 41 in wasm-gui/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

casting to the same type is unnecessary (`usize` -> `usize`)

warning: casting to the same type is unnecessary (`usize` -> `usize`)
  --> wasm-gui/src/lib.rs:41:25
   |
41 |                 vec![0; expected_size as usize]
   |                         ^^^^^^^^^^^^^^^^^^^^^^ help: try: `expected_size`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
   = note: `#[warn(clippy::unnecessary_cast)]` on by default

Check warning on line 74 in core/src/sound/volume_envelope.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `VolumeEnvelope`

warning: you should consider adding a `Default` implementation for `VolumeEnvelope`
  --> core/src/sound/volume_envelope.rs:65:5
   |
65 | /     pub fn new() -> VolumeEnvelope {
66 | |         VolumeEnvelope {
67 | |             initial_volume: 0,
68 | |             direction: EnvelopeDirection::Down,
...  |
73 | |         }
74 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
   |
19 + impl Default for VolumeEnvelope {
20 +     fn default() -> Self {
21 +         Self::new()
22 +     }
23 + }
   |

Check warning on line 53 in core/src/sound/length_function.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `LengthFunction`

warning: you should consider adding a `Default` implementation for `LengthFunction`
  --> core/src/sound/length_function.rs:45:5
   |
45 | /     pub fn new() -> LengthFunction {
46 | |         LengthFunction {
47 | |             channel_enabled: true,
48 | |             timer: 0,
...  |
52 | |         }
53 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
   |
12 + impl Default for LengthFunction {
13 +     fn default() -> Self {
14 +         Self::new()
15 +     }
16 + }
   |

Check warning on line 82 in core/src/sound/channel4.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this match could be replaced by its body itself

warning: this match could be replaced by its body itself
  --> core/src/sound/channel4.rs:80:9
   |
80 | /         match address {
81 | |             _ => 0, //panic!("Unimplemented APU Channel 4 read {:#06x}", address)
82 | |         }
   | |_________^ help: consider using the match body instead: `0`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding

Check warning on line 32 in core/src/sound/channel4.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `APUChannel4`

warning: you should consider adding a `Default` implementation for `APUChannel4`
  --> core/src/sound/channel4.rs:22:5
   |
22 | /     pub fn new() -> APUChannel4 {
23 | |         APUChannel4 {
24 | |             frequency_timer: 1,
25 | |             length_function: LengthFunction::new(),
...  |
31 | |         }
32 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
   |
21 + impl Default for APUChannel4 {
22 +     fn default() -> Self {
23 +         Self::new()
24 +     }
25 + }
   |

Check warning on line 122 in core/src/sound/channel3.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

manual implementation of an assign operation

warning: manual implementation of an assign operation
   --> core/src/sound/channel3.rs:115:9
    |
115 | /         wave_nibble = wave_nibble
116 | |             >> match self.volume_shift {
117 | |                 0 => 4,
118 | |                 1 => 0,
...   |
121 | |                 _ => unreachable!(),
122 | |             };
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
help: replace it with
    |
115 ~         wave_nibble >>= match self.volume_shift {
116 +                 0 => 4,
117 +                 1 => 0,
118 +                 2 => 1,
119 +                 3 => 2,
120 +                 _ => unreachable!(),
121 ~             };
    |

Check warning on line 28 in core/src/sound/channel3.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `APUChannel3`

warning: you should consider adding a `Default` implementation for `APUChannel3`
  --> core/src/sound/channel3.rs:18:5
   |
18 | /     pub fn new() -> APUChannel3 {
19 | |         APUChannel3 {
20 | |             frequency: 0,
21 | |             frequency_timer: 1,
...  |
27 | |         }
28 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
   |
17 + impl Default for APUChannel3 {
18 +     fn default() -> Self {
19 +         Self::new()
20 +     }
21 + }
   |

Check warning on line 68 in core/src/sound/channel2.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this match could be replaced by its body itself

warning: this match could be replaced by its body itself
  --> core/src/sound/channel2.rs:66:9
   |
66 | /         match address {
67 | |             _ => 0, //panic!("Unimplemented APU Channel 2 read {:#06x}", address)
68 | |         }
   | |_________^ help: consider using the match body instead: `0`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding

Check warning on line 27 in core/src/sound/channel2.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `APUChannel2`

warning: you should consider adding a `Default` implementation for `APUChannel2`
  --> core/src/sound/channel2.rs:18:5
   |
18 | /     pub fn new() -> APUChannel2 {
19 | |         APUChannel2 {
20 | |             frequency: 0,
21 | |             frequency_timer: 1,
...  |
26 | |         }
27 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
   |
17 + impl Default for APUChannel2 {
18 +     fn default() -> Self {
19 +         Self::new()
20 +     }
21 + }
   |

Check warning on line 161 in core/src/sound/channel1.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this match could be replaced by its body itself

warning: this match could be replaced by its body itself
   --> core/src/sound/channel1.rs:159:9
    |
159 | /         match address {
160 | |             _ => 0, //panic!("Unimplemented APU Channel 2 read {:#06x}", address)
161 | |         }
    | |_________^ help: consider using the match body instead: `0`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
    = note: `#[warn(clippy::match_single_binding)]` on by default

Check warning on line 87 in core/src/sound/channel1.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

manual implementation of an assign operation

warning: manual implementation of an assign operation
  --> core/src/sound/channel1.rs:87:13
   |
87 |             new_frequency = self.shadow_frequency + new_frequency;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `new_frequency += self.shadow_frequency`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern

Check warning on line 54 in core/src/sound/channel1.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `APUChannel1`

warning: you should consider adding a `Default` implementation for `APUChannel1`
  --> core/src/sound/channel1.rs:37:5
   |
37 | /     pub fn new() -> APUChannel1 {
38 | |         APUChannel1 {
39 | |             enabled: false,
40 | |             frequency: 0,
...  |
53 | |         }
54 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
   |
36 + impl Default for APUChannel1 {
37 +     fn default() -> Self {
38 +         Self::new()
39 +     }
40 + }
   |

Check warning on line 193 in core/src/sound/apu.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `APU`

warning: you should consider adding a `Default` implementation for `APU`
   --> core/src/sound/apu.rs:175:5
    |
175 | /     pub fn new() -> APU {
176 | |         APU {
177 | |             // These might be meant to start 0, not sure
178 | |             stereo_left_volume: 1.,
...   |
192 | |         }
193 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
    |
38  + impl Default for APU {
39  +     fn default() -> Self {
40  +         Self::new()
41  +     }
42  + }
    |

Check warning on line 66 in core/src/serial_cable.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `SerialCable`

warning: you should consider adding a `Default` implementation for `SerialCable`
  --> core/src/serial_cable.rs:58:5
   |
58 | /     pub fn new() -> SerialCable {
59 | |         SerialCable {
60 | |             transfer_data_byte: 0,
61 | |             transfer_control_byte: 0,
...  |
65 | |         }
66 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
   |
18 + impl Default for SerialCable {
19 +     fn default() -> Self {
20 +         Self::new()
21 +     }
22 + }
   |

Check warning on line 297 in core/src/memory/memory.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> core/src/memory/memory.rs:297:42
    |
297 |             palette_ram: PaletteRam::new(&target),
    |                                          ^^^^^^^ help: change this to: `target`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

Check warning on line 4 in core/src/memory/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

module has the same name as its containing module

warning: module has the same name as its containing module
 --> core/src/memory/mod.rs:4:1
  |
4 | pub mod memory;
  | ^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception

Check warning on line 45 in core/src/memory/mbcs/mbc3.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

manual implementation of an assign operation

warning: manual implementation of an assign operation
  --> core/src/memory/mbcs/mbc3.rs:45:17
   |
45 |                 n = n & bitmask;
   |                 ^^^^^^^^^^^^^^^ help: replace it with: `n &= bitmask`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
   = note: `#[warn(clippy::assign_op_pattern)]` on by default

Check warning on line 106 in core/src/lcd.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `LcdStatus`

warning: you should consider adding a `Default` implementation for `LcdStatus`
   --> core/src/lcd.rs:103:5
    |
103 | /     pub fn new() -> LcdStatus {
104 | |         // LCD starts in OAMSearch, not HBlank
105 | |         LcdStatus::from(0b000000_10)
106 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
    |
64  + impl Default for LcdStatus {
65  +     fn default() -> Self {
66  +         Self::new()
67  +     }
68  + }
    |

Check warning on line 18 in core/src/lcd.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `LcdControl`

warning: you should consider adding a `Default` implementation for `LcdControl`
  --> core/src/lcd.rs:15:5
   |
15 | /     pub fn new() -> LcdControl {
16 | |         // This value is set by the DMG boot rom.
17 | |         LcdControl::from(0b10000101)
18 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
   |
14 + impl Default for LcdControl {
15 +     fn default() -> Self {
16 +         Self::new()
17 +     }
18 + }
   |

Check warning on line 83 in core/src/joypad.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `Joypad`

warning: you should consider adding a `Default` implementation for `Joypad`
  --> core/src/joypad.rs:71:5
   |
71 | /     pub fn new() -> Joypad {
72 | |         Joypad {
73 | |             readout_mode: JoypadReadoutMode::Buttons,
74 | |             up_pressed: false,
...  |
82 | |         }
83 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
   |
23 + impl Default for Joypad {
24 +     fn default() -> Self {
25 +         Self::new()
26 +     }
27 + }
   |

Check warning on line 111 in core/src/interrupts.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you should consider adding a `Default` implementation for `Interrupts`

warning: you should consider adding a `Default` implementation for `Interrupts`
   --> core/src/interrupts.rs:104:5
    |
104 | /     pub fn new() -> Interrupts {
105 | |         Interrupts {
106 | |             enable: InterruptFields::new(),
107 | |             flag: InterruptFields::new(),
...   |
110 | |         }
111 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
    |
71  + impl Default for Interrupts {
72  +     fn default() -> Self {
73  +         Self::new()
74  +     }
75  + }
    |