From f6abdcc001cd0ecddec48e753c2009121036e5f6 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Tue, 17 Sep 2024 16:29:57 +0100 Subject: [PATCH] Allow unused in `macros.rs` docs The example code in macros.rs is much clearer as it is than changing it to remove the warnings created by adding the warn attribute to the `lib.rs` file. The example code was enclosed within a function block and `#[allow(unused)]` added. And a warn attribute added to `lib.rs`. --- internals/src/lib.rs | 1 + internals/src/macros.rs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internals/src/lib.rs b/internals/src/lib.rs index 353234b5d..ff78d9581 100644 --- a/internals/src/lib.rs +++ b/internals/src/lib.rs @@ -10,6 +10,7 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] // Coding conventions. #![warn(missing_docs)] +#![doc(test(attr(warn(unused))))] // Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #![allow(clippy::manual_range_contains)] // More readable than clippy's format. diff --git a/internals/src/macros.rs b/internals/src/macros.rs index f51f692d3..d0ae5bbb1 100644 --- a/internals/src/macros.rs +++ b/internals/src/macros.rs @@ -158,6 +158,8 @@ macro_rules! const_assert { /// # Examples /// /// ```rust +/// # #[allow(unused)] +/// # fn main() { /// # use core::fmt::{Display, Debug}; /// use bitcoin_internals::impl_from_infallible; /// @@ -167,7 +169,7 @@ macro_rules! const_assert { /// enum BetaEnum<'b> { Item(&'b usize) } /// impl_from_infallible!(BetaEnum<'b>); /// -/// enum GammaEnum { Item(T) }; +/// enum GammaEnum { Item(T) } /// impl_from_infallible!(GammaEnum); /// /// enum DeltaEnum<'b, 'a: 'static + 'b, T: 'a, D: Debug + Display + 'a> { @@ -189,6 +191,7 @@ macro_rules! const_assert { /// what: &'b D, /// } /// impl_from_infallible!(DeltaStruct<'b, 'a: 'static + 'b, T: 'a, D: Debug + Display + 'a>); +/// # } /// ``` /// /// See for more information about this macro. @@ -208,7 +211,7 @@ macro_rules! impl_from_infallible { /// Adds an implementation of `pub fn to_hex(&self) -> String` if `alloc` feature is enabled. /// /// The added function allocates a `String` then calls through to [`core::fmt::LowerHex`]. -/// +/// /// Note: Calling this macro assumes that the calling crate has an `alloc` feature that also activates the /// `alloc` crate. Calling this macro without the `alloc` feature enabled is a no-op. #[macro_export]