From 0e9f8e3b5b3506ac64403b1e894af87dcb95481e Mon Sep 17 00:00:00 2001 From: Andreas Molzer Date: Sat, 5 Nov 2022 13:25:20 +0100 Subject: [PATCH] Mark more tag enums as non_exhaustive --- src/decoder/ifd.rs | 8 +------- src/decoder/image.rs | 1 - src/decoder/mod.rs | 1 - src/tags.rs | 5 +---- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/decoder/ifd.rs b/src/decoder/ifd.rs index d028ebb..b05513d 100644 --- a/src/decoder/ifd.rs +++ b/src/decoder/ifd.rs @@ -17,6 +17,7 @@ use self::Value::{ #[allow(unused_qualifications)] #[derive(Debug, Clone, PartialEq)] +#[non_exhaustive] pub enum Value { Byte(u8), Short(u16), @@ -34,8 +35,6 @@ pub enum Value { Ascii(String), Ifd(u32), IfdBig(u64), - #[doc(hidden)] // Do not match against this. - __NonExhaustive, } impl Value { @@ -361,7 +360,6 @@ impl Entry { | Type::RATIONAL | Type::SRATIONAL | Type::IFD8 => 8, - Type::__NonExhaustive => unreachable!(), }; let value_bytes = match self.count.checked_mul(tag_size) { @@ -398,7 +396,6 @@ impl Entry { | Type::SLONG | Type::FLOAT | Type::IFD => unreachable!(), - Type::__NonExhaustive => unreachable!(), }); } @@ -444,7 +441,6 @@ impl Entry { reader.goto_offset(self.r(bo).read_u32()?.into())?; IfdBig(reader.read_u64()?) } - Type::__NonExhaustive => unreachable!(), }); } @@ -528,7 +524,6 @@ impl Entry { | Type::IFD8 => { unreachable!() } - Type::__NonExhaustive => unreachable!(), } } @@ -611,7 +606,6 @@ impl Entry { } Ok(Ascii(String::from_utf8(out)?)) } - Type::__NonExhaustive => unreachable!(), } } diff --git a/src/decoder/image.rs b/src/decoder/image.rs index 5106a88..c5c884f 100644 --- a/src/decoder/image.rs +++ b/src/decoder/image.rs @@ -464,7 +464,6 @@ impl Image { TiffUnsupportedError::FloatingPointPredictor(color_type), )); } - Predictor::__NonExhaustive => unreachable!(), }, (type_, _) => { return Err(TiffError::UnsupportedError( diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index d3fa2da..5fa1812 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -429,7 +429,6 @@ fn fix_endianness_and_predict( _ => unreachable!("Caller should have validated arguments. Please file a bug."), } } - Predictor::__NonExhaustive => unreachable!(), } } diff --git a/src/tags.rs b/src/tags.rs index 04cb5ec..cbf7472 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -9,11 +9,9 @@ macro_rules! tags { } => { $( #[$enum_attr] )* #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] + #[non_exhaustive] pub enum $name { $($(#[$ident_attr])* $tag,)* - // FIXME: switch to non_exhaustive once stabilized and compiler requirement new enough - #[doc(hidden)] - __NonExhaustive, $( #[doc = $unknown_doc] Unknown($ty), @@ -34,7 +32,6 @@ macro_rules! tags { match *self { $( $name::$tag => $val, )* $( $name::Unknown(n) => { $unknown_doc; n }, )* - $name::__NonExhaustive => unreachable!(), } } }