define_extension_trait: allow 'where T: Bound' and `where T = Type` clauses on methods
What changed, and why it matters
This commit is a small, internal change to a Rust macro that generates extension traits. It simply allows the macro to accept method signatures that include 'where' clauses (a Rust language feature for adding type constraints). There is no change to user-facing behavior, no bug fix, and no security relevance.
No security action needed. This is a benign macro syntax enhancement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The define_extension_trait! macro in bitcoin/src/internal_macros.rs is updated to optionally parse where T: Bound and where T = Type clauses on method signatures. The change is purely syntactic: three lines are modified to add a $(where ...)? fragment in the macro matcher and its two expansion sites (trait declaration and impl block). The commit message states this is preparatory work for later gating script methods on subtraits. No runtime code, cryptographic logic, or public API behavior is changed.
Changed components
bitcoin/src/internal_macros.rsInspect captured patch +3 / −3
diff --git a/bitcoin/src/internal_macros.rs b/bitcoin/src/internal_macros.rs
index 69cbfcc2..0f7774e5 100644
--- a/bitcoin/src/internal_macros.rs
+++ b/bitcoin/src/internal_macros.rs
@@ -249,7 +249,7 @@ macro_rules! define_extension_trait {
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
$(
$(#[$($fn_attrs:tt)*])*
- fn $fn:ident$(<$($gen:ident: $gent:path),*>)?($($params:tt)*) $( -> $ret:ty )? $body:block
+ fn $fn:ident$(<$($gen:ident: $gent:path),*>)?($($params:tt)*) $( -> $ret:ty )? $(where $wherety:ident $(= $whereeq:ident)? $(: $wherebound:ident)?)? $body:block
)*
}) => {
#[cfg_attr(docsrs, doc(notable_trait))]
@@ -258,7 +258,7 @@ macro_rules! define_extension_trait {
$crate::internal_macros::only_doc_attrs! {
{ $(#[$($fn_attrs)*])* },
{
- fn $fn$(<$($gen: $gent),*>)?($($params)*) $( -> $ret )?;
+ fn $fn$(<$($gen: $gent),*>)?($($params)*) $( -> $ret)? $(where $wherety $(= $whereeq)? $(: $wherebound)?)?;
}
}
)*
@@ -269,7 +269,7 @@ macro_rules! define_extension_trait {
$crate::internal_macros::only_non_doc_attrs! {
{ $(#[$($fn_attrs)*])* },
{
- fn $fn$(<$($gen: $gent),*>)?($($params)*) $( -> $ret )? $body
+ fn $fn$(<$($gen: $gent),*>)?($($params)*) $( -> $ret )? $(where $wherety $(= $whereeq)? $(: $wherebound)?)? $body
}
}
)*
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.