diff --git a/src/dynimage.rs b/src/dynimage.rs index e4edbe543c..f415a29700 100644 --- a/src/dynimage.rs +++ b/src/dynimage.rs @@ -686,11 +686,16 @@ impl DynamicImage { /// Encode this image and write it to ```w``` pub fn write_to>( &self, + #[allow(unused_variables)] + // When no features are supported w: &mut W, format: F, ) -> ImageResult<()> { + #[allow(unused_variables,unused_mut)] let mut bytes = self.to_bytes(); + #[allow(unused_variables)] let (width, height) = self.dimensions(); + #[allow(unused_variables,unused_mut)] let mut color = self.color(); let format = format.into(); diff --git a/src/image.rs b/src/image.rs index d45b77a6ba..045f6a8328 100644 --- a/src/image.rs +++ b/src/image.rs @@ -135,6 +135,8 @@ impl From for ImageOutputFormat { // This struct manages buffering associated with implementing `Read` and `Seek` on decoders that can // must decode ranges of bytes at a time. +#[allow(dead_code)] +// When no image formats that use it are enabled pub(crate) struct ImageReadBuffer { scanline_bytes: usize, buffer: Vec, @@ -149,6 +151,8 @@ impl ImageReadBuffer { /// Panics if scanline_bytes doesn't fit into a usize, because that would mean reading anything /// from the image would take more RAM than the entire virtual address space. In other words, /// actually using this struct would instantly OOM so just get it out of the way now. + #[allow(dead_code)] + // When no image formats that use it are enabled pub(crate) fn new(scanline_bytes: u64, total_bytes: u64) -> Self { Self { scanline_bytes: usize::try_from(scanline_bytes).unwrap(), @@ -159,6 +163,8 @@ impl ImageReadBuffer { } } + #[allow(dead_code)] + // When no image formats that use it are enabled pub(crate) fn read(&mut self, buf: &mut [u8], mut read_scanline: F) -> io::Result where F: FnMut(&mut [u8]) -> io::Result, @@ -204,6 +210,8 @@ impl ImageReadBuffer { /// Decodes a specific region of the image, represented by the rectangle /// starting from ```x``` and ```y``` and having ```length``` and ```width``` +#[allow(dead_code)] +// When no image formats that use it are enabled pub(crate) fn load_rect<'a, D, F, F1, F2, E>(x: u32, y: u32, width: u32, height: u32, buf: &mut [u8], progress_callback: F, decoder: &mut D, diff --git a/src/io/free_functions.rs b/src/io/free_functions.rs index fde27fd620..62d8160e2e 100644 --- a/src/io/free_functions.rs +++ b/src/io/free_functions.rs @@ -33,7 +33,9 @@ use crate::color; use crate::image; use crate::dynimage::DynamicImage; use crate::error::{ImageError, ImageFormatHint, ImageResult}; -use crate::image::{ImageDecoder, ImageEncoder, ImageFormat}; +use crate::image::ImageFormat; +#[allow(unused_imports)] // When no features are supported +use crate::image::{ImageDecoder, ImageEncoder}; /// Internal error type for guessing format from path. pub(crate) enum PathError { @@ -58,8 +60,10 @@ pub(crate) fn open_impl(path: &Path) -> ImageResult { /// Try [`io::Reader`] for more advanced uses. /// /// [`io::Reader`]: io/struct.Reader.html +#[allow(unused_variables)] +// r is unused if no features are supported. pub fn load(r: R, format: ImageFormat) -> ImageResult { - #[allow(deprecated, unreachable_patterns)] + #[allow(unreachable_patterns)] // Default is unreachable if all features are supported. match format { #[cfg(feature = "png")] @@ -99,11 +103,14 @@ pub(crate) fn image_dimensions_impl(path: &Path) -> ImageResult<(u32, u32)> { image_dimensions_with_format_impl(fin, format) } +#[allow(unused_variables)] +// fin is unused if no features are supported. pub(crate) fn image_dimensions_with_format_impl(fin: R, format: ImageFormat) -> ImageResult<(u32, u32)> { - #[allow(unreachable_patterns)] + #[allow(unreachable_patterns,unreachable_code)] // Default is unreachable if all features are supported. + // Code after the match is unreachable if none are. Ok(match format { #[cfg(feature = "jpeg")] image::ImageFormat::Jpeg => jpeg::JpegDecoder::new(fin)?.dimensions(), @@ -133,6 +140,8 @@ pub(crate) fn image_dimensions_with_format_impl(fin: R, forma }) } +#[allow(unused_variables)] +// Most variables when no features are supported pub(crate) fn save_buffer_impl( path: &Path, buf: &[u8], @@ -177,6 +186,8 @@ pub(crate) fn save_buffer_impl( } } +#[allow(unused_variables)] +// Most variables when no features are supported pub(crate) fn save_buffer_with_format_impl( path: &Path, buf: &[u8], diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 3728443646..4b4fda670b 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -36,6 +36,8 @@ where /// Expand a buffer of packed 1, 2, or 4 bits integers into u8's. Assumes that /// every `row_size` entries there are padding bits up to the next byte boundry. +#[allow(dead_code)] +// When no image formats that use it are enabled pub(crate) fn expand_bits(bit_depth: u8, row_size: u32, buf: &[u8]) -> Vec { // Note: this conversion assumes that the scanlines begin on byte boundaries let mask = (1u8 << bit_depth as usize) - 1; @@ -63,11 +65,15 @@ pub(crate) fn expand_bits(bit_depth: u8, row_size: u32, buf: &[u8]) -> Vec { p } +#[allow(dead_code)] +// When no image formats that use it are enabled pub(crate) fn vec_u16_into_u8(vec: Vec) -> Vec { // Do this way until we find a way to not alloc/dealloc but get llvm to realloc instead. vec_u16_copy_u8(&vec) } +#[allow(dead_code)] +// When no image formats that use it are enabled pub(crate) fn vec_u16_copy_u8(vec: &[u16]) -> Vec { let mut new = vec![0; vec.len() * mem::size_of::()]; NativeEndian::write_u16_into(&vec[..], &mut new[..]);