Fix mrsv lint warnings#1744
Conversation
Coverage Report for CI Build 29586100405Coverage remained the same at 86.187%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
| #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
| pub enum SessionEvent { | ||
| Created(SessionContext), | ||
| Created(Box<SessionContext>), |
There was a problem hiding this comment.
I could also go with #[allow(clippy::large_enum_variant)] instead here
There was a problem hiding this comment.
My preference would depend on whether Serialize/Deserialize is affected by the Box<> change. If it changes the persistence format then this is breaking change, which I'm not sure is worth it for an MSRV lint. I'm also curious why this particular lint is msrv-only, did clippy change the way it determines what constitutes a large variant?
There was a problem hiding this comment.
Looks like this is from rust-lang/rust-clippy#14717 which followed up rust-lang/rust-clippy#13833 so I don't think this is really a variable behavior just something that was/is buggy?
As for serialization / deserialization I believe that Box<> is transparent to serde. testing that now.
There was a problem hiding this comment.
I tested to confirm and the json outputs are identical from before and after e1f956a. And here is the source that i believe proves the behavior for serialization. https://docs.rs/serde_core/1.0.228/src/serde_core/ser/impls.rs.html#460-490
There was a problem hiding this comment.
Cool. I'm still leaning towards ignoring that lint if it's being raised due to a bug in 1.85 anyway?
There was a problem hiding this comment.
Fair enough, since it's non-breaking we can always add this down the line. I am going to try and get an answer on the expected behavior for this lint and confirm that it's not broken now but that can be a follow-up
There was a problem hiding this comment.
Hmm this is especialy odd considering the sender SessionEvent does wrap SessionContext in a Box<> as the lint fails there even on nightly
There was a problem hiding this comment.
Ok, so not a bug, just how the lint works. It compares against the second largest variant in nightly and looks for a difference > 200 bytes as an enum is limited by the largest variant so a large size discrepancy leaves room for optimization but if all, or many, of the variants are large it doesn't matter. Whereas in older versions it just looks for any variant > 200 bytes. This is why the sender needs the Box even on nightly as there are not other equally large variants there.
rust-payjoin/payjoin/src/core/send/v2/session.rs
Lines 159 to 168 in 218d8ae
While the receiver has variants that contain the entire PSBT etc
rust-payjoin/payjoin/src/core/receive/v2/session.rs
Lines 196 to 212 in 218d8ae
Edit: this is wrong
There was a problem hiding this comment.
It was my first guess afterall with rust-lang/rust-clippy#14717 where is_normalizable returns false for some variants in this case likely bitcoin::Psbt. Because the receiver SessionEvent contains several variants relating to Psbts there was always going to be a large discrepancy as they would be of size 0 in 1.85.0. I made the assumption above that the lint became a comparator since 1.85.0 to now but it has been a comparator since before 1.63.0. The removal of the is_normalizable and related logic in nightly now calculate variant sizes more accurately.
fc0e6b2 to
db047da
Compare
|
rebased with a TODO explaining the discrepancy needs a closer look |
db047da to
439f895
Compare
Closes #1743
This is less impactful than I first thought in the issue since the
SessionContextis a private fieldPull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.