Skip to content

Commit 1a6e435

Browse files
committed
features: Drop no-assert-string in favour of deku_error!() behaviour
The deku_error!() macro will discard dynamic formatting when it's unavailable due to feature selection. Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
1 parent 8f599c1 commit 1a6e435

File tree

4 files changed

+1
-14
lines changed

4 files changed

+1
-14
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ default = ["std", "bits"]
2424
std = ["deku_derive/std", "bitvec?/std", "alloc", "no_std_io/std"]
2525
alloc = ["bitvec?/alloc", "deku_derive/alloc", "no_std_io/alloc" ]
2626
logging = ["deku_derive/logging", "log"]
27-
no-assert-string = ["deku_derive/no-assert-string"]
2827
bits = ["dep:bitvec", "deku_derive/bits", "alloc" ]
2928

3029
[dependencies]

deku-derive/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ proc-macro = true
1616
std = ["proc-macro-crate", "alloc"]
1717
alloc = []
1818
logging = []
19-
no-assert-string = []
2019
bits = []
2120

2221
[dependencies]

deku-derive/src/macros/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,6 @@ fn assertion_failed(
417417
} else {
418418
quote! { stringify!(#v) }
419419
};
420-
#[cfg(feature = "no-assert-string")]
421-
{
422-
quote! {
423-
return Err(::#crate_::DekuError::AssertionNoStr);
424-
}
425-
}
426-
#[cfg(not(feature = "no-assert-string"))]
427420
{
428421
quote! {
429422
return Err(::#crate_::deku_error!(::#crate_::DekuError::Assertion, "Field failed assertion", "{}.{}: {}", #ident, #field_ident_str, #stringify));

src/error.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ pub enum DekuError {
4949
InvalidParam(DekuErrorString),
5050
/// Assertion error from `assert` or `assert_eq` attributes
5151
Assertion(DekuErrorString),
52-
/// Assertion error from `assert` or `assert_eq` attributes, without string
53-
AssertionNoStr,
5452
/// Could not resolve `id` for variant
5553
IdVariantNotFound,
5654
/// IO error while reading or writing
@@ -158,8 +156,7 @@ impl core::fmt::Display for DekuError {
158156
),
159157
DekuError::Parse(ref err) => write!(f, "Parse error: {err}"),
160158
DekuError::InvalidParam(ref err) => write!(f, "Invalid param error: {err}"),
161-
DekuError::Assertion(ref err) => write!(f, "Assertion error: {err}"),
162-
DekuError::AssertionNoStr => write!(f, "Assertion error"),
159+
DekuError::Assertion(ref err) => write!(f, "{err}"),
163160
DekuError::IdVariantNotFound => write!(f, "Could not resolve `id` for variant"),
164161
DekuError::Io(ref e) => write!(f, "io errorr: {e:?}"),
165162
}
@@ -182,7 +179,6 @@ impl From<DekuError> for std::io::Error {
182179
DekuError::Parse(_) => io::Error::new(io::ErrorKind::InvalidData, error),
183180
DekuError::InvalidParam(_) => io::Error::new(io::ErrorKind::InvalidInput, error),
184181
DekuError::Assertion(_) => io::Error::new(io::ErrorKind::InvalidData, error),
185-
DekuError::AssertionNoStr => io::Error::from(io::ErrorKind::InvalidData),
186182
DekuError::IdVariantNotFound => io::Error::new(io::ErrorKind::NotFound, error),
187183
DekuError::Io(e) => io::Error::new(e, error),
188184
}

0 commit comments

Comments
 (0)