Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings #851

Merged
merged 4 commits into from
Mar 1, 2024
Merged

Fix clippy warnings #851

merged 4 commits into from
Mar 1, 2024

Conversation

ameknite
Copy link
Contributor

@ameknite ameknite commented Feb 28, 2024

fix clippy warnings

warning: unneeded unit return type
  --> src/host/coreaudio/macos/property_listener.rs:11:55
   |
11 | struct PropertyListenerCallbackWrapper(Box<dyn FnMut() -> ()>);
   |                                                       ^^^^^^ help: remove the `-> ()`
   |
   = 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

warning: unneeded unit return type
  --> src/host/coreaudio/macos/property_listener.rs:24:26
   |
24 |     pub fn new<F: FnMut() -> () + 'static>(
   |                          ^^^^^^ help: remove the `-> ()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit

warning: using `clone` on type `SupportedBufferSize` which implements the `Copy` trait
   --> src/host/coreaudio/macos/mod.rs:309:34
    |
309 |                     buffer_size: buffer_size.clone(),
    |                                  ^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `buffer_size`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
    = note: `#[warn(clippy::clone_on_copy)]` on by default

warning: casting raw pointers to the same type and constness is unnecessary (`*const host::coreaudio::coreaudio::coreaudio_sys::AudioBuffer` -> `*const host::coreaudio::coreaudio::coreaudio_sys::AudioBuffer`)
   --> src/host/coreaudio/macos/mod.rs:571:23
    |
571 |             let ptr = (*args.data.data).mBuffers.as_ptr() as *const AudioBuffer;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*args.data.data).mBuffers.as_ptr()`
    |
    = 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

warning: casting to the same type is unnecessary (`usize` -> `usize`)
   --> src/host/coreaudio/macos/mod.rs:583:23
    |
583 |             let len = (data_byte_size as usize / bytes_per_channel) as usize;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(data_byte_size as usize / bytes_per_channel)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting to the same type is unnecessary (`usize` -> `usize`)
   --> src/host/coreaudio/macos/mod.rs:688:23
    |
688 |             let len = (data_byte_size as usize / bytes_per_channel) as usize;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(data_byte_size as usize / bytes_per_channel)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: usage of an `Arc` that is not `Send` and `Sync`
   --> src/host/coreaudio/macos/mod.rs:891:20
    |
891 |             inner: Arc::new(Mutex::new(inner)),
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `Arc<Mutex<StreamInner>>` is not `Send` and `Sync` as:
    = note: - the trait `Send` is not implemented for `Mutex<StreamInner>`
    = note: - the trait `Sync` is not implemented for `Mutex<StreamInner>`
    = help: consider using an `Rc` instead. `Arc` does not provide benefits for non `Send` and `Sync` types
    = note: if you intend to use `Arc` with `Send` and `Sync` traits
    = note: wrap the inner type with a `Mutex` or implement `Send` and `Sync` for `Mutex<StreamInner>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
    = note: `#[warn(clippy::arc_with_non_send_sync)]` on by default

warning: casting to the same type is unnecessary (`u32` -> `u32`)
  --> src/host/coreaudio/mod.rs:55:30
   |
55 |         SampleFormat::F32 => (kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked) as u32,
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting to the same type is unnecessary (`u32` -> `u32`)
  --> src/host/coreaudio/mod.rs:56:14
   |
56 |         _ => kAudioFormatFlagIsPacked as u32,
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `kAudioFormatFlagIsPacked`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: `cpal` (lib) generated 9 warnings (run `cargo clippy --fix --lib -p cpal` to apply 7 suggestions)
warning: useless use of `vec!`
   --> src/lib.rs:745:23
    |
745 |       let mut formats = vec![
    |  _______________________^
746 | |         SupportedStreamConfigRange {
747 | |             buffer_size: SupportedBufferSize::Range { min: 256, max: 512 },
748 | |             channels: 2,
...   |
780 | |         },
781 | |     ];
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec
    = note: `#[warn(clippy::useless_vec)]` on by default
help: you can use an array directly
    |
745 ~     let mut formats = [SupportedStreamConfigRange {
746 +             buffer_size: SupportedBufferSize::Range { min: 256, max: 512 },
747 +             channels: 2,
748 +             min_sample_rate: SampleRate(1),
749 +             max_sample_rate: SampleRate(96000),
750 +             sample_format: SampleFormat::F32,
751 +         },
752 +         SupportedStreamConfigRange {
753 +             buffer_size: SupportedBufferSize::Range { min: 256, max: 512 },
754 +             channels: 1,
755 +             min_sample_rate: SampleRate(1),
756 +             max_sample_rate: SampleRate(96000),
757 +             sample_format: SampleFormat::F32,
758 +         },
759 +         SupportedStreamConfigRange {
760 +             buffer_size: SupportedBufferSize::Range { min: 256, max: 512 },
761 +             channels: 2,
762 +             min_sample_rate: SampleRate(1),
763 +             max_sample_rate: SampleRate(96000),
764 +             sample_format: SampleFormat::I16,
765 +         },
766 +         SupportedStreamConfigRange {
767 +             buffer_size: SupportedBufferSize::Range { min: 256, max: 512 },
768 +             channels: 2,
769 +             min_sample_rate: SampleRate(1),
770 +             max_sample_rate: SampleRate(96000),
771 +             sample_format: SampleFormat::U16,
772 +         },
773 +         SupportedStreamConfigRange {
774 +             buffer_size: SupportedBufferSize::Range { min: 256, max: 512 },
775 +             channels: 2,
776 +             min_sample_rate: SampleRate(1),
777 +             max_sample_rate: SampleRate(22050),
778 +             sample_format: SampleFormat::F32,
779 ~         }];
    |

warning: `cpal` (lib test) generated 1 warning (run `cargo clippy --fix --lib -p cpal --tests` to apply 1 suggestion)
warning: this import is redundant
 --> examples/beep.rs:1:1
  |
1 | use anyhow;
  | ^^^^^^^^^^^ help: remove it entirely
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports
  = note: `#[warn(clippy::single_component_path_imports)]` on by default

@est31 est31 merged commit f894781 into RustAudio:master Mar 1, 2024
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants