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

refactor: mark {In, Out}boundOpenInfo as deprecated #5242

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

drHuangMHT
Copy link
Contributor

@drHuangMHT drHuangMHT commented Mar 18, 2024

Description

Mark {In, Out}boundOpenInfo as deprecated.
May close #3268.

Notes & open questions

I'm putting off formatting until the change has been accepted for clearer diff.
I have changed all occurrence of OpenInfo with concrete type wherever possible to avoid excessive use of #[allow(deprecated)]. Is this optimal ?

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@drHuangMHT drHuangMHT marked this pull request as ready for review December 2, 2024 07:02
@drHuangMHT
Copy link
Contributor Author

drHuangMHT commented Dec 2, 2024

@jxs Got a moment to review this? It seems that I cannot assign a reviewer because I don't have the permission, so I have to do an @ mention.

@elenaf9 elenaf9 requested review from jxs and elenaf9 December 7, 2024 19:04
Copy link
Contributor

@elenaf9 elenaf9 left a comment

Choose a reason for hiding this comment

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

Thank you @drHuangMHT, for this PR, and all of your recent contributions in general!

I think we might be able to avoid some of the #[allow(deprecated)] if we add defaults to the types that currently include {Inbound, Outbound}Info generics (if they are trailing), e.g. to ConnectionEvent. That way the deprecated types won't need to be mentioned by the handlers anymore. Wdyt?

swarm/src/connection.rs Outdated Show resolved Hide resolved
swarm/src/handler.rs Outdated Show resolved Hide resolved
swarm/tests/connection_close.rs Outdated Show resolved Hide resolved
@drHuangMHT
Copy link
Contributor Author

I think we might be able to avoid some of the #[allow(deprecated)] if we add defaults to the types that currently include {Inbound, Outbound}Info generics (if they are trailing)

What about those that are not(whose OpenInfo generic parameter in the middle)? I gave it a shot and it came out quite terrible because I had to reorder the parameters in every implementation. I think the impact will basically be the same as we outright removed {In,Out}boundOpenInfo without a deprecation warning, or even worse because the error messages are rather confusing.

@elenaf9
Copy link
Contributor

elenaf9 commented Dec 10, 2024

What about those that are not(whose OpenInfo generic parameter in the middle)? I gave it a shot and it came out quite terrible because I had to reorder the parameters in every implementation. I think the impact will basically be the same as we outright removed {In,Out}boundOpenInfo without a deprecation warning, or even worse because the error messages are rather confusing.

Yeah, I'd leave those as they are (=> your current implementation).

Copy link
Contributor

@elenaf9 elenaf9 left a comment

Choose a reason for hiding this comment

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

One more comment about using expect instead of allow in all places, rest lgtm!

@@ -47,6 +47,7 @@ impl<TConnectionHandler, TMap, TNewIn> MapInEvent<TConnectionHandler, TNewIn, TM
}
}

#[allow(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
Copy link
Contributor

Choose a reason for hiding this comment

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

With RFC 2383, expect is now stabilized: rust-lang/rust#120924. By using expect instead of allow, we'll get a warning if the deprecated items have been removed and the allow/ expect isn't needed anymore.

Question: Is our CI on a recent enough version to support expect?

Copy link
Contributor

Choose a reason for hiding this comment

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

(same for all other places where we add allow(deprecated) in this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Question: Is our CI on a recent enough version to support expect?

It was stabilized in 1.81, I believe our current workflow is on 1.80, which may not support this unless they have backported (branched on Jun 7 vs merged on Jun 27) it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed with #5730 :)

Copy link
Contributor

@elenaf9 elenaf9 Dec 11, 2024

Choose a reason for hiding this comment

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

Well actually, if we do use expect we must update our MSRV, i.e. merge #5650.

@drHuangMHT
Copy link
Contributor Author

Waiting for #5730 for better handling of deprecation warning bypass?

@elenaf9 elenaf9 mentioned this pull request Dec 11, 2024
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.

swarm: Deprecate ConnectionHandler::{In,Out}boundOpenInfo
3 participants