Skip to content

Commit

Permalink
build: Use trait Error from core
Browse files Browse the repository at this point in the history
Since Rust 1.81, the `trait Error` is available in core. Therefore `std` is no longer needed for error types
  • Loading branch information
caspermeijn committed Oct 23, 2024
1 parent 86f87a2 commit bed812d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ authors = [
]
license = "Apache-2.0"
repository = "https://github.com/tokio-rs/prost"
rust-version = "1.71.1"
rust-version = "1.81"
edition = "2021"

[profile.bench]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benches/dataset.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{criterion_group, criterion_main, Criterion};
use prost::Message;
use std::error::Error;
use core::error::Error;

pub mod benchmarks {
include!(concat!(env!("OUT_DIR"), "/benchmarks.rs"));
Expand Down
3 changes: 1 addition & 2 deletions prost-types/src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ impl fmt::Display for DurationError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for DurationError {}
impl core::error::Error for DurationError {}

impl FromStr for Duration {
type Err = DurationError;
Expand Down
3 changes: 1 addition & 2 deletions prost-types/src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ impl fmt::Display for TimestampError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for TimestampError {}
impl core::error::Error for TimestampError {}

#[cfg(feature = "std")]
impl TryFrom<Timestamp> for std::time::SystemTime {
Expand Down
9 changes: 3 additions & 6 deletions prost/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ impl fmt::Display for DecodeError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for DecodeError {}
impl core::error::Error for DecodeError {}

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

#[cfg(feature = "std")]
impl std::error::Error for EncodeError {}
impl core::error::Error for EncodeError {}

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

#[cfg(feature = "std")]
impl std::error::Error for UnknownEnumValue {}
impl core::error::Error for UnknownEnumValue {}

0 comments on commit bed812d

Please sign in to comment.