-
Notifications
You must be signed in to change notification settings - Fork 292
Fix compiler warnings for unused code when compiling without decoder #834
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,6 +101,7 @@ pub struct Decoder<R: Read + Seek>(DecoderImpl<R>); | |
| pub struct LoopedDecoder<R: Read + Seek> { | ||
| /// The underlying decoder implementation. | ||
| inner: Option<DecoderImpl<R>>, | ||
|
|
||
| /// Configuration settings for the decoder. | ||
| settings: Settings, | ||
| } | ||
|
|
@@ -249,7 +250,10 @@ impl<R: Read + Seek> DecoderImpl<R> { | |
| DecoderImpl::Mp3(source) => source.try_seek(pos), | ||
| #[cfg(feature = "symphonia")] | ||
| DecoderImpl::Symphonia(source, PhantomData) => source.try_seek(pos), | ||
| DecoderImpl::None(_, _) => unreachable!(), | ||
| DecoderImpl::None(_, _) => { | ||
| let _ = pos; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trick here is to make the argument
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Starting a variable with underscore is used for unused variables.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use it as
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but naming it |
||
| unreachable!() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -622,6 +626,7 @@ where | |
|
|
||
| // Take ownership of the decoder to reset it | ||
| let decoder = self.inner.take()?; | ||
|
|
||
| let (new_decoder, sample) = match decoder { | ||
| #[cfg(all(feature = "hound", not(feature = "symphonia-wav")))] | ||
| DecoderImpl::Wav(source) => { | ||
|
|
@@ -667,9 +672,16 @@ where | |
| let sample = source.next(); | ||
| (DecoderImpl::Symphonia(source, PhantomData), sample) | ||
| } | ||
| DecoderImpl::None(unreachable, phantom) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then the code after the match statement is dead code and causes a warning. |
||
| let _ = self.settings; | ||
| (DecoderImpl::None(unreachable, phantom), None) | ||
| } | ||
| }; | ||
| self.inner = Some(new_decoder); | ||
| sample | ||
|
|
||
| { | ||
| self.inner = Some(new_decoder); | ||
| sample | ||
| } | ||
| } else { | ||
| None | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ use std::sync::Arc; | |
| use crate::{ | ||
| buffer::SamplesBuffer, | ||
| common::{assert_error_traits, ChannelCount, SampleRate}, | ||
| math, BitDepth, Float, Sample, | ||
| math, Float, Sample, | ||
| }; | ||
|
|
||
| use dasp_sample::FromSample; | ||
|
|
@@ -231,7 +231,7 @@ pub trait Source: Iterator<Item = Sample> { | |
| #[cfg(feature = "dither")] | ||
| #[cfg_attr(docsrs, doc(cfg(feature = "dither")))] | ||
| #[inline] | ||
| fn dither(self, target_bits: BitDepth, algorithm: DitherAlgorithm) -> Dither<Self> | ||
| fn dither(self, target_bits: crate::BitDepth, algorithm: DitherAlgorithm) -> Dither<Self> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is your rationale here?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you import We can also put the import behind a feature flag, but then we end up with feature-gated stuff spread more out and it's just easier to accidentally mess up.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| where | ||
| Self: Sized, | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tagging
#[allow(unused_variables)]may convey intent more clearly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. It would just allow unused variables (generally) and I think it would need to go on the function scope, and you'd want to only disable the lint for
not(feature = "symphonia").In my opinion the last block - whether symphonia is enabled, or not - should use the data somehow, and that's what this does.
It's late and I think I'm failing to describe why I think using
let _ = data;is better. Maybe tomorrow it will be clearer for either of us.