Skip to content

Commit 1f773b9

Browse files
committed
Feature gate the segwit::EncodeError
This error is only used if the "alloc" feature is enabled, feature gate it.
1 parent 9aca6a9 commit 1f773b9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/segwit.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ impl From<SegwitHrpstringError> for DecodeError {
374374
/// An error while constructing a [`SegwitHrpstring`] type.
375375
#[derive(Debug, Clone, PartialEq, Eq)]
376376
#[non_exhaustive]
377+
#[cfg(feature = "alloc")]
377378
pub enum EncodeError {
378379
/// Invalid witness version (must be 0-16 inclusive).
379380
WitnessVersion(InvalidWitnessVersionError),
@@ -385,6 +386,7 @@ pub enum EncodeError {
385386
Fmt(fmt::Error),
386387
}
387388

389+
#[cfg(feature = "alloc")]
388390
impl fmt::Display for EncodeError {
389391
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
390392
use EncodeError::*;
@@ -399,6 +401,7 @@ impl fmt::Display for EncodeError {
399401
}
400402

401403
#[cfg(feature = "std")]
404+
#[cfg(feature = "alloc")]
402405
impl std::error::Error for EncodeError {
403406
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
404407
use EncodeError::*;
@@ -412,21 +415,25 @@ impl std::error::Error for EncodeError {
412415
}
413416
}
414417

418+
#[cfg(feature = "alloc")]
415419
impl From<InvalidWitnessVersionError> for EncodeError {
416420
#[inline]
417421
fn from(e: InvalidWitnessVersionError) -> Self { Self::WitnessVersion(e) }
418422
}
419423

424+
#[cfg(feature = "alloc")]
420425
impl From<WitnessLengthError> for EncodeError {
421426
#[inline]
422427
fn from(e: WitnessLengthError) -> Self { Self::WitnessLength(e) }
423428
}
424429

430+
#[cfg(feature = "alloc")]
425431
impl From<SegwitCodeLengthError> for EncodeError {
426432
#[inline]
427433
fn from(e: SegwitCodeLengthError) -> Self { Self::TooLong(e) }
428434
}
429435

436+
#[cfg(feature = "alloc")]
430437
impl From<fmt::Error> for EncodeError {
431438
#[inline]
432439
fn from(e: fmt::Error) -> Self { Self::Fmt(e) }

0 commit comments

Comments
 (0)