Skip to content

Commit 3211dc5

Browse files
authored
build: Use trait Error from core (#1179)
Since Rust 1.81, the `trait Error` is available in core. Therefore `std` is no longer needed for error types
1 parent dfbd0b0 commit 3211dc5

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

benchmarks/benches/dataset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use core::error::Error;
12
use criterion::{criterion_group, criterion_main, Criterion};
23
use prost::Message;
3-
use std::error::Error;
44

55
pub mod benchmarks {
66
include!(concat!(env!("OUT_DIR"), "/benchmarks.rs"));

prost-types/src/duration.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ impl fmt::Display for DurationError {
164164
}
165165
}
166166

167-
#[cfg(feature = "std")]
168-
impl std::error::Error for DurationError {}
167+
impl core::error::Error for DurationError {}
169168

170169
impl FromStr for Duration {
171170
type Err = DurationError;

prost-types/src/timestamp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ impl fmt::Display for TimestampError {
185185
}
186186
}
187187

188-
#[cfg(feature = "std")]
189-
impl std::error::Error for TimestampError {}
188+
impl core::error::Error for TimestampError {}
190189

191190
#[cfg(feature = "std")]
192191
impl TryFrom<Timestamp> for std::time::SystemTime {

prost/src/error.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ impl fmt::Display for DecodeErrorKind {
145145
}
146146
}
147147

148-
#[cfg(feature = "std")]
149-
impl std::error::Error for DecodeError {}
148+
impl core::error::Error for DecodeError {}
150149

151150
#[cfg(feature = "std")]
152151
impl From<DecodeError> for std::io::Error {
@@ -196,8 +195,7 @@ impl fmt::Display for EncodeError {
196195
}
197196
}
198197

199-
#[cfg(feature = "std")]
200-
impl std::error::Error for EncodeError {}
198+
impl core::error::Error for EncodeError {}
201199

202200
#[cfg(feature = "std")]
203201
impl From<EncodeError> for std::io::Error {
@@ -220,8 +218,7 @@ impl fmt::Display for UnknownEnumValue {
220218
}
221219
}
222220

223-
#[cfg(feature = "std")]
224-
impl std::error::Error for UnknownEnumValue {}
221+
impl core::error::Error for UnknownEnumValue {}
225222

226223
#[cfg(test)]
227224
mod test {

0 commit comments

Comments
 (0)