Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive Eq for all structs that derive PartialEq #1763

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

gcomte
Copy link
Contributor

@gcomte gcomte commented Oct 11, 2022

Fixes #1762

I'm not entirely sure about the legitimacy of this commit but according to the Rust docs, deriving Eq for a struct makes sure that all of it's fields are Eq as well:

Note that the derive strategy requires all fields are Eq

If I understand this premise correctly, this commit should not introduce any equivalence false positives.

@@ -609,7 +609,7 @@ mod tests {

const EVENT_DEADLINE: u64 = 5 * FRESHNESS_TIMER;

#[derive(Clone, Eq, Hash, PartialEq)]
#[derive(Clone, Eq, Hash, PartialEq, Eq)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already derived Eq, no change needed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed: eed1287

@TheBlueMatt
Copy link
Collaborator

LGTM. Can you squash the second commit into the first so that its one commit?

@gcomte
Copy link
Contributor Author

gcomte commented Oct 11, 2022

LGTM. Can you squash the second commit into the first so that its one commit?

Done

@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2022

Codecov Report

Base: 90.79% // Head: 90.76% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (4483baf) compared to base (6738fd5).
Patch coverage: 89.47% of modified lines in pull request are covered.

❗ Current head 4483baf differs from pull request most recent head aa916bb. Consider uploading reports for the commit aa916bb to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1763      +/-   ##
==========================================
- Coverage   90.79%   90.76%   -0.04%     
==========================================
  Files          87       87              
  Lines       46969    46969              
  Branches    46969    46969              
==========================================
- Hits        42646    42631      -15     
- Misses       4323     4338      +15     
Impacted Files Coverage Δ
lightning-background-processor/src/lib.rs 96.23% <0.00%> (ø)
lightning/src/chain/mod.rs 68.18% <33.33%> (ø)
lightning-invoice/src/lib.rs 87.48% <50.00%> (ø)
lightning/src/ln/chan_utils.rs 94.55% <80.00%> (ø)
lightning/src/chain/package.rs 93.04% <88.88%> (ø)
lightning/src/ln/msgs.rs 86.24% <90.00%> (ø)
lightning-block-sync/src/lib.rs 93.33% <100.00%> (ø)
lightning-block-sync/src/poll.rs 87.77% <100.00%> (ø)
lightning/src/chain/channelmonitor.rs 91.16% <100.00%> (-0.06%) ⬇️
lightning/src/chain/keysinterface.rs 92.54% <100.00%> (ø)
... and 19 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -679,7 +679,7 @@ impl Readable for IrrevocablyResolvedHTLC {
/// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
/// the "reorg path" (ie disconnecting blocks until you find a common ancestor from both the
/// returned block hash and the the current chain and then reconnecting blocks to get to the
/// best chain) upon deserializing the object!
/// best chain) upon deserializing the object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems unrelated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm sorry. Gonna remove

@gcomte gcomte force-pushed the feature/derive-eq branch 2 times, most recently from 091b06a to d65c670 Compare October 11, 2022 22:32
@@ -824,6 +824,7 @@ pub type TransactionOutputs = (Txid, Vec<(u32, TxOut)>);
#[cfg(any(test, fuzzing, feature = "_test_utils"))]
/// Used only in testing and fuzzing to check serialization roundtrips don't change the underlying
/// object
impl<Signer: Sign> Eq for ChannelMonitor<Signer> {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, see the cfg above (here and the next hunk) - we were only implementing eq for test/fuzzing here, so we'll need to duplicate the cfg (or just not bother - its test-only code anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added changes in a speperate commit for you to see: 4483baf

If legitimate, I'll squash the commits.

@dunxen
Copy link
Contributor

dunxen commented Oct 13, 2022

Probably best to just leave out the impls for the test code as Matt suggested instead of adding more cfgs :)

Otherwise, LGTM

dunxen
dunxen previously approved these changes Oct 14, 2022
@gcomte
Copy link
Contributor Author

gcomte commented Oct 14, 2022

Squashed the commits ✔️

@TheBlueMatt TheBlueMatt merged commit e61f3a2 into lightningdevkit:main Oct 17, 2022
@gcomte gcomte deleted the feature/derive-eq branch October 25, 2022 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Structs derive PartialEq but not Eq
5 participants