Skip to content

Commit bed812d

Browse files
committed
build: Use trait Error from core
Since Rust 1.81, the `trait Error` is available in core. Therefore `std` is no longer needed for error types
1 parent 86f87a2 commit bed812d

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ authors = [
2626
]
2727
license = "Apache-2.0"
2828
repository = "https://github.com/tokio-rs/prost"
29-
rust-version = "1.71.1"
29+
rust-version = "1.81"
3030
edition = "2021"
3131

3232
[profile.bench]

benchmarks/benches/dataset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use criterion::{criterion_group, criterion_main, Criterion};
22
use prost::Message;
3-
use std::error::Error;
3+
use core::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
@@ -172,8 +172,7 @@ impl fmt::Display for DurationError {
172172
}
173173
}
174174

175-
#[cfg(feature = "std")]
176-
impl std::error::Error for DurationError {}
175+
impl core::error::Error for DurationError {}
177176

178177
impl FromStr for Duration {
179178
type Err = DurationError;

prost-types/src/timestamp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ impl fmt::Display for TimestampError {
199199
}
200200
}
201201

202-
#[cfg(feature = "std")]
203-
impl std::error::Error for TimestampError {}
202+
impl core::error::Error for TimestampError {}
204203

205204
#[cfg(feature = "std")]
206205
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
@@ -71,8 +71,7 @@ impl fmt::Display for DecodeError {
7171
}
7272
}
7373

74-
#[cfg(feature = "std")]
75-
impl std::error::Error for DecodeError {}
74+
impl core::error::Error for DecodeError {}
7675

7776
#[cfg(feature = "std")]
7877
impl From<DecodeError> for std::io::Error {
@@ -122,8 +121,7 @@ impl fmt::Display for EncodeError {
122121
}
123122
}
124123

125-
#[cfg(feature = "std")]
126-
impl std::error::Error for EncodeError {}
124+
impl core::error::Error for EncodeError {}
127125

128126
#[cfg(feature = "std")]
129127
impl From<EncodeError> for std::io::Error {
@@ -146,5 +144,4 @@ impl fmt::Display for UnknownEnumValue {
146144
}
147145
}
148146

149-
#[cfg(feature = "std")]
150-
impl std::error::Error for UnknownEnumValue {}
147+
impl core::error::Error for UnknownEnumValue {}

0 commit comments

Comments
 (0)