Skip to content

Fix mrsv lint warnings#1744

Merged
spacebear21 merged 1 commit into
payjoin:masterfrom
benalleng:msrv-lint-warnings
Jul 17, 2026
Merged

Fix mrsv lint warnings#1744
spacebear21 merged 1 commit into
payjoin:masterfrom
benalleng:msrv-lint-warnings

Conversation

@benalleng

Copy link
Copy Markdown
Collaborator

Closes #1743

This is less impactful than I first thought in the issue since the SessionContext is a private field

Pull Request Checklist

Please confirm the following before requesting review:

@coveralls

coveralls commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 29586100405

Coverage remained the same at 86.187%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15963
Covered Lines: 13758
Line Coverage: 86.19%
Coverage Strength: 345.63 hits per line

💛 - Coveralls

@caarloshenriq caarloshenriq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK

Comment thread payjoin/src/core/receive/v2/session.rs Outdated
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum SessionEvent {
Created(SessionContext),
Created(Box<SessionContext>),

@benalleng benalleng Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I could also go with #[allow(clippy::large_enum_variant)] instead here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

@benalleng benalleng Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cool. I'm still leaning towards ignoring that lint if it's being raised due to a bug in 1.85 anyway?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hmm this is especialy odd considering the sender SessionEvent does wrap SessionContext in a Box<> as the lint fails there even on nightly

@benalleng benalleng Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

pub enum SessionEvent {
/// Sender was created with session data
Created(Box<SessionContext>),
/// Sender POSTed the Original PSBT and is waiting to receive a Proposal PSBT
PostedOriginalPsbt(),
/// User initiated cancellation of the session
Cancelled(),
/// Closed successful or failed session
Closed(SessionOutcome),
}

While the receiver has variants that contain the entire PSBT etc

pub enum SessionEvent {
Created(SessionContext),
RetrievedOriginalPayload { original: OriginalPayload, reply_key: Option<crate::HpkePublicKey> },
CheckedBroadcastSuitability(),
CheckedInputsNotOwned(),
CheckedNoInputsSeenBefore(),
IdentifiedReceiverOutputs(Vec<usize>),
CommittedOutputs { outputs: Vec<bitcoin::TxOut>, change_vout: usize },
CommittedInputs { receiver_inputs: Vec<InputPair>, payjoin_psbt: bitcoin::Psbt },
AppliedFeeRange(PsbtContext),
FinalizedProposal(bitcoin::Psbt),
GotReplyableError(JsonReply),
PostedPayjoinProposal(),
Cancelled,
ProtocolFailed,
Closed(SessionOutcome),
}

Edit: this is wrong

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

@benalleng
benalleng force-pushed the msrv-lint-warnings branch 3 times, most recently from fc0e6b2 to db047da Compare July 17, 2026 13:28
@benalleng
benalleng requested a review from spacebear21 July 17, 2026 13:46
@benalleng

Copy link
Copy Markdown
Collaborator Author

rebased with a TODO explaining the discrepancy needs a closer look

@benalleng
benalleng force-pushed the msrv-lint-warnings branch from db047da to 439f895 Compare July 17, 2026 13:59

@spacebear21 spacebear21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK

@spacebear21
spacebear21 merged commit 1e06c8b into payjoin:master Jul 17, 2026
24 checks passed
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.

Should we care about msrv lint warnings for 1.0?

4 participants