Skip to content

Lifetime elision warnings in iterator methods #854

@BRIGHTON-ASUMANI

Description

@BRIGHTON-ASUMANI

Fix lifetime elision warnings in iterator methods

Description

The codebase currently has 8 compiler warnings about "hiding a lifetime that's elided elsewhere is confusing" in various iterator method signatures. These warnings make the code less clear and clutter the compiler output.

Current Behavior

When running cargo test --all-targets --all-features, the following warnings appear:

warning: hiding a lifetime that's elided elsewhere is confusing
   --> src/descriptor/mod.rs:291:26
    |
291 |     pub fn tap_tree_iter(&self) -> tr::TapTreeIter<Pk> {
    |                          ^^^^^     ------------------- the same lifetime is hidden here
    |                          |
    |                          the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: use `'_` for type paths
    |
291 |     pub fn tap_tree_iter(&self) -> tr::TapTreeIter<'_, Pk> {
    |                                                    +++

Similar warnings appear in:

  • src/descriptor/tr/mod.rs
  • src/descriptor/tr/spend_info.rs
  • src/descriptor/tr/taptree.rs
  • src/miniscript/iter.rs
  • src/policy/concrete.rs
  • src/primitives/threshold.rs

Expected Behavior

All iterator method signatures should use explicit lifetime parameters ('_) to make the code more clear and eliminate compiler warnings.

Impact

  • Low risk: Purely cosmetic changes that don't affect functionality
  • High benefit: Eliminates 8 compiler warnings and improves code clarity
  • No breaking changes: All existing APIs remain unchanged
  • Follows Rust best practices: Makes lifetime relationships explicit

Proposed Solution

Add explicit '_ lifetime parameters to the following method signatures:

// Before
pub fn tap_tree_iter(&self) -> tr::TapTreeIter<Pk> {

// After  
pub fn tap_tree_iter(&self) -> tr::TapTreeIter<'_, Pk> {

This change should be applied to all 8 affected methods across the 7 files mentioned above.

Additional Context

This is a straightforward fix that improves code quality without any functional changes. All tests continue to pass after the changes, confirming no regressions are introduced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions