Skip to content

Commit c18cafc

Browse files
committed
Remove deprecated error descriptions
Error descriptions are soft-deprecated since 1.27.0, and hard-deprecated since 1.42.0. Our MSRV is 1.36.0 so well above the 1.27.0 bound. See also rust-lang/rust#66919
1 parent a75799c commit c18cafc

File tree

3 files changed

+29
-39
lines changed

3 files changed

+29
-39
lines changed

src/audio.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,17 @@ impl From<()> for AudioReadError {
5151
}
5252
}
5353

54-
impl error::Error for AudioReadError {
55-
fn description(&self) -> &str {
56-
match self {
57-
&AudioReadError::EndOfPacket => "End of packet reached.",
58-
&AudioReadError::AudioBadFormat => "Invalid audio packet",
59-
&AudioReadError::AudioIsHeader => "The vorbis version is not supported",
60-
&AudioReadError::BufferNotAddressable => "Requested to create buffer of non-addressable size",
61-
}
62-
}
63-
}
54+
impl error::Error for AudioReadError {}
6455

6556
impl fmt::Display for AudioReadError {
6657
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
67-
write!(fmt, "{}", error::Error::description(self))
58+
let description = match self {
59+
AudioReadError::EndOfPacket => "End of packet reached.",
60+
AudioReadError::AudioBadFormat => "Invalid audio packet",
61+
AudioReadError::AudioIsHeader => "The vorbis version is not supported",
62+
AudioReadError::BufferNotAddressable => "Requested to create buffer of non-addressable size",
63+
};
64+
write!(fmt, "{}", description)
6865
}
6966
}
7067

@@ -120,7 +117,7 @@ fn floor_zero_decode(rdr :&mut BitpackCursor, codebooks :&[Codebook],
120117
// This channel is unused in this frame,
121118
// its all zeros.
122119
return Err(FloorSpecialCase::Unused);
123-
}
120+
}
124121

125122
let booknumber = try!(rdr.read_dyn_u32(
126123
::ilog(fl.floor0_number_of_books as u64)));
@@ -268,7 +265,7 @@ fn extr_neighbor<F>(v :&[u32], max_idx :usize,
268265
// the criterion of being "smaller" than bound
269266
let min_idx = prefix.iter()
270267
.position(|&val| smaller(val, bound))
271-
.unwrap_or_else(||
268+
.unwrap_or_else(||
272269
panic!("No index y < {0} found where v[y] is {1} than v[{0}] = 0x{2:08x}!",
273270
max_idx, relation, bound));
274271

src/header.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,21 @@ impl From<FromUtf8Error> for HeaderReadError {
9292
}
9393
}
9494

95-
impl error::Error for HeaderReadError {
96-
fn description(&self) -> &str {
97-
match self {
98-
&HeaderReadError::EndOfPacket => "End of packet reached.",
99-
&HeaderReadError::NotVorbisHeader => "The packet is not a vorbis header",
100-
&HeaderReadError::UnsupportedVorbisVersion => "The vorbis version is not supported",
101-
&HeaderReadError::HeaderBadFormat => "Invalid header",
102-
&HeaderReadError::HeaderBadType(_) => "Invalid/unexpected header type",
103-
&HeaderReadError::HeaderIsAudio => "Packet seems to be audio",
104-
&HeaderReadError::Utf8DecodeError => "UTF-8 decoding error",
105-
&HeaderReadError::BufferNotAddressable => "Requested to create buffer of non-addressable size",
106-
}
107-
}
108-
}
95+
impl error::Error for HeaderReadError {}
10996

11097
impl fmt::Display for HeaderReadError {
11198
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
112-
write!(fmt, "{}", error::Error::description(self))
99+
let description = match self {
100+
HeaderReadError::EndOfPacket => "End of packet reached.",
101+
HeaderReadError::NotVorbisHeader => "The packet is not a vorbis header",
102+
HeaderReadError::UnsupportedVorbisVersion => "The vorbis version is not supported",
103+
HeaderReadError::HeaderBadFormat => "Invalid header",
104+
HeaderReadError::HeaderBadType(_) => "Invalid/unexpected header type",
105+
HeaderReadError::HeaderIsAudio => "Packet seems to be audio",
106+
HeaderReadError::Utf8DecodeError => "UTF-8 decoding error",
107+
HeaderReadError::BufferNotAddressable => "Requested to create buffer of non-addressable size",
108+
};
109+
write!(fmt, "{}", description)
113110
}
114111
}
115112

src/lib.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,16 @@ pub enum VorbisError {
123123
OggError(OggReadError),
124124
}
125125

126-
impl std::error::Error for VorbisError {
127-
fn description(&self) -> &str {
128-
match self {
129-
&VorbisError::BadAudio(_) => "Vorbis bitstream audio decode problem",
130-
&VorbisError::BadHeader(_) => "Vorbis bitstream header decode problem",
131-
#[cfg(feature = "ogg")]
132-
&VorbisError::OggError(ref e) => e.description(),
133-
}
134-
}
135-
}
126+
impl std::error::Error for VorbisError {}
136127

137128
impl std::fmt::Display for VorbisError {
138129
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
139-
write!(fmt, "{}", std::error::Error::description(self))
130+
write!(fmt, "{}", match self {
131+
VorbisError::BadAudio(_) => "Vorbis bitstream audio decode problem",
132+
VorbisError::BadHeader(_) => "Vorbis bitstream header decode problem",
133+
#[cfg(feature = "ogg")]
134+
VorbisError::OggError(_) => "Ogg decode problem",
135+
})
140136
}
141137
}
142138

0 commit comments

Comments
 (0)