Repository: rust-bitcoin/rust-bitcoin (language: rust)

Issue:
Remove TODO in lint list in `units/Cargo.toml`
In #3704 we added all pedantic lints to the `units` manifest but left same marked as `allow` with a `TODO` comment.

Close this issue by resolving and removing all `TODO`s in the list.


Discussion / hints:
This is the clippy reference page: https://rust-lang.github.io/rust-clippy/master/index.html

Fix patch:
diff --git a/units/Cargo.toml b/units/Cargo.toml
index d0368dace..fd49837da 100644
--- a/units/Cargo.toml
+++ b/units/Cargo.toml
@@ -129,7 +129,7 @@ redundant_closure_for_method_calls = "warn"
 redundant_else = "warn"
 ref_as_ptr = "warn"
 ref_binding_to_reference = "warn"
-ref_option = "allow" # TODO: Still neds considering.
+ref_option = "warn"
 ref_option_ref = "warn"
 return_self_not_must_use = "warn"
 same_functions_in_if_condition = "warn"
diff --git a/units/src/amount/serde.rs b/units/src/amount/serde.rs
index e7be0fd5d..36c56ec35 100644
--- a/units/src/amount/serde.rs
+++ b/units/src/amount/serde.rs
@@ -207,6 +207,7 @@ pub mod as_sat {
         use super::private;
         use crate::amount::serde::SerdeAmountForOpt;
 
+        #[allow(clippy::ref_option)] // API forced by serde.
         pub fn serialize<A: SerdeAmountForOpt, S: Serializer>(
             a: &Option<A>,
             s: S,
@@ -277,6 +278,7 @@ pub mod as_btc {
         use super::private;
         use crate::amount::serde::SerdeAmountForOpt;
 
+        #[allow(clippy::ref_option)] // API forced by serde.
         pub fn serialize<A: SerdeAmountForOpt, S: Serializer>(
             a: &Option<A>,
             s: S,
@@ -347,6 +349,7 @@ pub mod as_str {
         use super::private;
         use crate::amount::serde::SerdeAmountForOpt;
 
+        #[allow(clippy::ref_option)] // API forced by serde.
         pub fn serialize<A: SerdeAmountForOpt, S: Serializer>(
             a: &Option<A>,
             s: S,
diff --git a/units/src/fee_rate/serde.rs b/units/src/fee_rate/serde.rs
index cd914c322..b5b616816 100644
--- a/units/src/fee_rate/serde.rs
+++ b/units/src/fee_rate/serde.rs
@@ -53,6 +53,7 @@ pub mod as_sat_per_kwu {
 
         use crate::FeeRate;
 
+        #[allow(clippy::ref_option)] // API forced by serde.
         pub fn serialize<S: Serializer>(f: &Option<FeeRate>, s: S) -> Result<S::Ok, S::Error> {
             match *f {
                 Some(f) => s.serialize_some(&f.to_sat_per_kwu()),
@@ -124,6 +125,7 @@ pub mod as_sat_per_vb_floor {
         use crate::fee_rate::serde::OverflowError;
         use crate::fee_rate::FeeRate;
 
+        #[allow(clippy::ref_option)] // API forced by serde.
         pub fn serialize<S: Serializer>(f: &Option<FeeRate>, s: S) -> Result<S::Ok, S::Error> {
             match *f {
                 Some(f) => s.serialize_some(&f.to_sat_per_vb_floor()),
@@ -199,6 +201,7 @@ pub mod as_sat_per_vb_ceil {
         use crate::fee_rate::serde::OverflowError;
         use crate::fee_rate::FeeRate;
 
+        #[allow(clippy::ref_option)] // API forced by serde.
         pub fn serialize<S: Serializer>(f: &Option<FeeRate>, s: S) -> Result<S::Ok, S::Error> {
             match *f {
                 Some(f) => s.serialize_some(&f.to_sat_per_vb_ceil()),


Test patch: