Merge rust-bitcoin/rust-bitcoin#3474: Remove `allow_unused` flag in serde

49914c50f4 Remove `allow_unused` flag in serde (Jamil Lambert, PhD)

Pull request description:

  In serde `#[allow(unused_variables)]` has been dropped and the unused variables have been "used" when `debug_assertions` is off.

  Close #3332

ACKs for top commit:
  tcharding:
    ACK 49914c50f4
  apoelstra:
    ACK 49914c50f4 successfully ran local tests

Tree-SHA512: c83703f91abb5ce513f6403375ce3b2cb24d5200272c98f0a5e532fe41dda1aae8a5334ee8868751e156457f1cfe6b4fe08849fb5329bfbb1c12ed18364e0b1c
This commit is contained in:
merge-script 2024-10-16 12:03:47 +00:00
commit 73bb017d78
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 6 additions and 3 deletions

View File

@ -159,7 +159,6 @@ struct DisplayWrapper<'a, T: 'a + Encodable, E>(&'a T, PhantomData<E>);
impl<'a, T: 'a + Encodable, E: ByteEncoder> fmt::Display for DisplayWrapper<'a, T, E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut writer = IoWrapper::<'_, _, E::Encoder>::new(f, E::default().into());
#[allow(unused_variables)] // When debug_assertions are not enabled.
self.0.consensus_encode(&mut writer).map_err(|error| {
#[cfg(debug_assertions)]
{
@ -174,6 +173,8 @@ impl<'a, T: 'a + Encodable, E: ByteEncoder> fmt::Display for DisplayWrapper<'a,
);
}
}
#[cfg(not(debug_assertions))]
let _ = error;
fmt::Error
})?;
let result = writer.actually_flush();
@ -200,7 +201,6 @@ impl<W: fmt::Write> ErrorTrackingWriter<W> {
}
#[track_caller]
#[allow(unused_variables)] // When debug_assertions are not enabled.
fn assert_no_error(&self, fun: &str) {
#[cfg(debug_assertions)]
{
@ -208,6 +208,8 @@ impl<W: fmt::Write> ErrorTrackingWriter<W> {
panic!("`{}` called on errored writer", fun);
}
}
#[cfg(not(debug_assertions))]
let _ = fun;
}
fn assert_was_error<Offender>(&self) {
@ -219,12 +221,13 @@ impl<W: fmt::Write> ErrorTrackingWriter<W> {
}
}
#[allow(unused_variables)] // When debug_assertions are not enabled.
fn set_error(&mut self, was: bool) {
#[cfg(debug_assertions)]
{
self.was_error |= was;
}
#[cfg(not(debug_assertions))]
let _ = was;
}
fn check_err<T, E>(&mut self, result: Result<T, E>) -> Result<T, E> {