From f9be30ddbe5c0837ab3e408dfadabc6c6cd2068e Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Mon, 13 Jan 2025 19:16:32 +0000 Subject: [PATCH] units: Fix `missing_errors_doc` clippy lint Change the lint to `warn` in `units/Cargo.toml`. Allow `missing_errors_doc` in `amount/serde.rs` and `fee_rate/serde.rs`. Add missing `# Errors` sections to rustdocs where the lint gives a warning. --- units/Cargo.toml | 2 +- units/src/amount/serde.rs | 1 + units/src/fee_rate/serde.rs | 1 + units/src/locktime/absolute.rs | 8 ++++++++ units/src/parse.rs | 11 +++++++++-- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/units/Cargo.toml b/units/Cargo.toml index d0368dace..c0c33af40 100644 --- a/units/Cargo.toml +++ b/units/Cargo.toml @@ -105,7 +105,7 @@ match_wild_err_arm = "warn" match_wildcard_for_single_variants = "warn" maybe_infinite_iter = "warn" mismatching_type_param_order = "warn" -missing_errors_doc = "allow" # TODO: Still needs considering. +missing_errors_doc = "warn" missing_fields_in_debug = "warn" missing_panics_doc = "allow" # TODO: Still needs considering. must_use_candidate = "allow" # Useful for audit but many false positives. diff --git a/units/src/amount/serde.rs b/units/src/amount/serde.rs index e7be0fd5d..dc6a08e85 100644 --- a/units/src/amount/serde.rs +++ b/units/src/amount/serde.rs @@ -2,6 +2,7 @@ // methods are implementation of a standardized serde-specific signature #![allow(missing_docs)] +#![allow(clippy::missing_errors_doc)] //! This module adds serde serialization and deserialization support for amounts. //! diff --git a/units/src/fee_rate/serde.rs b/units/src/fee_rate/serde.rs index cd914c322..4ebd56e9b 100644 --- a/units/src/fee_rate/serde.rs +++ b/units/src/fee_rate/serde.rs @@ -3,6 +3,7 @@ // Module implements standardized serde-specific trait methods. #![allow(missing_docs)] #![allow(clippy::trivially_copy_pass_by_ref)] +#![allow(clippy::missing_errors_doc)] //! This module adds serde serialization and deserialization support for amounts. //! diff --git a/units/src/locktime/absolute.rs b/units/src/locktime/absolute.rs index b7ee722e6..fbc842fb7 100644 --- a/units/src/locktime/absolute.rs +++ b/units/src/locktime/absolute.rs @@ -41,6 +41,10 @@ impl Height { /// Constructs a new [`Height`] from a hex string. /// /// The input string may or may not contain a typical hex prefix e.g., `0x`. + /// + /// # Errors + /// + /// If the input string is not a valid hex representation of a block height. pub fn from_hex(s: &str) -> Result { parse_hex(s, Self::from_consensus) } @@ -139,6 +143,10 @@ impl Time { /// Constructs a new [`Time`] from a hex string. /// /// The input string may or may not contain a typical hex prefix e.g., `0x`. + /// + /// # Errors + /// + /// If the input string is not a valid hex representation of a block time. pub fn from_hex(s: &str) -> Result { parse_hex(s, Self::from_consensus) } /// Constructs a new block time. diff --git a/units/src/parse.rs b/units/src/parse.rs index 130a29462..6127a8f9e 100644 --- a/units/src/parse.rs +++ b/units/src/parse.rs @@ -76,22 +76,29 @@ mod sealed { /// Parses the input string as an integer returning an error carrying rich context. /// -/// On error this function allocates to copy the input string into the error return. If the caller -/// has a `String` or `Box` which is not used later it's better to call +/// If the caller has a `String` or `Box` which is not used later it's better to call /// [`parse::int_from_string`] or [`parse::int_from_box`] respectively. /// /// [`parse::int_from_string`]: crate::parse::int_from_string /// [`parse::int_from_box`]: crate::parse::int_from_box +/// +/// # Errors +/// +/// On error this function allocates to copy the input string into the error return. pub fn int_from_str(s: &str) -> Result { int(s) } /// Parses the input string as an integer returning an error carrying rich context. /// +/// # Errors +/// /// On error the input string is moved into the error return without allocating. #[cfg(feature = "alloc")] pub fn int_from_string(s: alloc::string::String) -> Result { int(s) } /// Parses the input string as an integer returning an error carrying rich context. /// +/// # Errors +/// /// On error the input string is converted into the error return without allocating. #[cfg(feature = "alloc")] pub fn int_from_box(s: alloc::boxed::Box) -> Result { int(s) }