Remove `allow_unused` flag in serde

In serde `#[allow(unused_variables)]` has been dropped and the unused
variables "used" when `debug_assertions` is off.
This commit is contained in:
Jamil Lambert, PhD 2024-10-15 14:40:54 +01:00
parent da462d67ef
commit 49914c50f4
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
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> { impl<'a, T: 'a + Encodable, E: ByteEncoder> fmt::Display for DisplayWrapper<'a, T, E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut writer = IoWrapper::<'_, _, E::Encoder>::new(f, E::default().into()); 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| { self.0.consensus_encode(&mut writer).map_err(|error| {
#[cfg(debug_assertions)] #[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 fmt::Error
})?; })?;
let result = writer.actually_flush(); let result = writer.actually_flush();
@ -200,7 +201,6 @@ impl<W: fmt::Write> ErrorTrackingWriter<W> {
} }
#[track_caller] #[track_caller]
#[allow(unused_variables)] // When debug_assertions are not enabled.
fn assert_no_error(&self, fun: &str) { fn assert_no_error(&self, fun: &str) {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
{ {
@ -208,6 +208,8 @@ impl<W: fmt::Write> ErrorTrackingWriter<W> {
panic!("`{}` called on errored writer", fun); panic!("`{}` called on errored writer", fun);
} }
} }
#[cfg(not(debug_assertions))]
let _ = fun;
} }
fn assert_was_error<Offender>(&self) { 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) { fn set_error(&mut self, was: bool) {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
{ {
self.was_error |= was; self.was_error |= was;
} }
#[cfg(not(debug_assertions))]
let _ = was;
} }
fn check_err<T, E>(&mut self, result: Result<T, E>) -> Result<T, E> { fn check_err<T, E>(&mut self, result: Result<T, E>) -> Result<T, E> {