Skip to content

Commit e39aa48

Browse files
committed
Merge bitcoindevkit#2137: Replace std::error::Error with core::error::Error
2a92fd3 chore: use `core::error::Error` (Luis Schwab) Pull request description: Closes bitcoindevkit#2132 The `Error` trait is stable as of 1.81.0, so import it from `core` instead. ACKs for top commit: evanlinjin: ACK 2a92fd3 Tree-SHA512: ce843843a932815b0991b4f5d064471876f103a4d2d8f12ac47eecfd1263ff79a833e937e81f1a98303f9002115dc792b6f4837d8752f49c6ab080762d510ee4
2 parents a6bfbd4 + 2a92fd3 commit e39aa48

9 files changed

Lines changed: 14 additions & 21 deletions

File tree

crates/bitcoind_rpc/src/bip158.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ impl core::fmt::Display for Error {
173173
}
174174
}
175175

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

179178
impl From<bitcoincore_rpc::Error> for Error {
180179
fn from(e: bitcoincore_rpc::Error) -> Self {

crates/chain/src/indexer/keychain_txout.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,7 @@ impl<K: core::fmt::Display> core::fmt::Display for InsertDescriptorError<K> {
10221022
}
10231023
}
10241024

1025-
#[cfg(feature = "std")]
1026-
impl<K: core::fmt::Display + core::fmt::Debug> std::error::Error for InsertDescriptorError<K> {}
1025+
impl<K: core::fmt::Display + core::fmt::Debug> core::error::Error for InsertDescriptorError<K> {}
10271026

10281027
/// `ChangeSet` represents persistent updates to a [`KeychainTxOutIndex`].
10291028
///

crates/chain/src/indexer/spk_txout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<I: Clone + Ord + core::fmt::Debug> SpkTxOutIndex<I> {
332332
/// # use bitcoin::{Address, Network, Transaction};
333333
/// # use std::str::FromStr;
334334
/// #
335-
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
335+
/// # fn example() -> Result<(), Box<dyn core::error::Error>> {
336336
/// let mut index = SpkTxOutIndex::<u32>::default();
337337
///
338338
/// // ... scan transactions to populate the index ...
@@ -382,7 +382,7 @@ impl<I: Clone + Ord + core::fmt::Debug> SpkTxOutIndex<I> {
382382
/// # use bitcoin::{Address, Network, Transaction};
383383
/// # use std::str::FromStr;
384384
/// #
385-
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
385+
/// # fn example() -> Result<(), Box<dyn core::error::Error>> {
386386
/// let mut index = SpkTxOutIndex::<u32>::default();
387387
///
388388
/// // ... scan transactions to populate the index ...

crates/chain/src/local_chain.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,7 @@ impl core::fmt::Display for MissingGenesisError {
498498
}
499499
}
500500

501-
#[cfg(feature = "std")]
502-
impl std::error::Error for MissingGenesisError {}
501+
impl core::error::Error for MissingGenesisError {}
503502

504503
/// Represents a failure when trying to insert/remove a checkpoint to/from [`LocalChain`].
505504
#[derive(Clone, Debug, PartialEq)]
@@ -529,8 +528,7 @@ impl core::fmt::Display for AlterCheckPointError {
529528
}
530529
}
531530

532-
#[cfg(feature = "std")]
533-
impl std::error::Error for AlterCheckPointError {}
531+
impl core::error::Error for AlterCheckPointError {}
534532

535533
/// Occurs when an update does not have a common checkpoint with the original chain.
536534
#[derive(Clone, Debug, PartialEq)]
@@ -549,8 +547,7 @@ impl core::fmt::Display for CannotConnectError {
549547
}
550548
}
551549

552-
#[cfg(feature = "std")]
553-
impl std::error::Error for CannotConnectError {}
550+
impl core::error::Error for CannotConnectError {}
554551

555552
/// The error type for [`LocalChain::apply_header_connected_to`].
556553
#[derive(Debug, Clone, PartialEq)]
@@ -573,8 +570,7 @@ impl core::fmt::Display for ApplyHeaderError {
573570
}
574571
}
575572

576-
#[cfg(feature = "std")]
577-
impl std::error::Error for ApplyHeaderError {}
573+
impl core::error::Error for ApplyHeaderError {}
578574

579575
/// Applies `update_tip` onto `original_tip`.
580576
///

crates/chain/src/rusqlite_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ impl ToSql for Impl<bitcoin::Network> {
185185
}
186186
}
187187

188-
fn from_sql_error<E: std::error::Error + Send + Sync + 'static>(err: E) -> FromSqlError {
188+
fn from_sql_error<E: core::error::Error + Send + Sync + 'static>(err: E) -> FromSqlError {
189189
FromSqlError::Other(Box::new(err))
190190
}
191191

192-
fn to_sql_error<E: std::error::Error + Send + Sync + 'static>(err: E) -> rusqlite::Error {
192+
fn to_sql_error<E: core::error::Error + Send + Sync + 'static>(err: E) -> rusqlite::Error {
193193
rusqlite::Error::ToSqlConversionFailure(Box::new(err))
194194
}
195195

crates/chain/src/tx_graph.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ impl fmt::Display for CalculateFeeError {
287287
}
288288
}
289289

290-
#[cfg(feature = "std")]
291-
impl std::error::Error for CalculateFeeError {}
290+
impl core::error::Error for CalculateFeeError {}
292291

293292
impl<A> TxGraph<A> {
294293
/// Iterate over all tx outputs known by [`TxGraph`].

crates/file_store/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ impl From<io::Error> for StoreError {
5353
}
5454
}
5555

56-
impl std::error::Error for StoreError {}
56+
impl core::error::Error for StoreError {}

crates/file_store/src/store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl<C> std::fmt::Display for StoreErrorWithDump<C> {
278278
}
279279
}
280280

281-
impl<C: fmt::Debug> std::error::Error for StoreErrorWithDump<C> {}
281+
impl<C: fmt::Debug> core::error::Error for StoreErrorWithDump<C> {}
282282

283283
#[cfg(test)]
284284
#[cfg_attr(coverage_nightly, coverage(off))]

examples/example_cli/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub fn create_tx<O: ChainOracle>(
268268
feerate: f32,
269269
) -> anyhow::Result<(Psbt, Option<ChangeInfo>)>
270270
where
271-
O::Error: std::error::Error + Send + Sync + 'static,
271+
O::Error: core::error::Error + Send + Sync + 'static,
272272
{
273273
let mut changeset = keychain_txout::ChangeSet::default();
274274

0 commit comments

Comments
 (0)