-
Notifications
You must be signed in to change notification settings - Fork 163
Description
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.