-
Notifications
You must be signed in to change notification settings - Fork 124
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
fix: feature flag Datagram::into_data #1695
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1695 +/- ##
=======================================
Coverage 92.97% 92.97%
=======================================
Files 120 120
Lines 37342 37342
=======================================
Hits 34718 34718
Misses 2624 2624 ☔ View full report in Codecov by Sentry. |
I don't get this error when I run |
@larseggert do you run
|
I ran it at the root. If there are issues with running it in the subdirectories, we should add that to CI. |
> Use cargo-hack to run clippy on each crate individually with its > respective default features only. Can reveal warnings otherwise > hidden given that a plain cargo clippy combines all features of the > workspace. See e.g. mozilla#1695.
3417707
to
cde3814
Compare
`Datagram::into_data` is used in `neqo_common::udp` only. `neqo_common::udp` is behind the `udp` feature. The feature is not part of the crate's default features. Thus a plain `cargo check` rightly complains with: ``` warning: method `into_data` is never used --> neqo-common/src/datagram.rs:58:19 | 20 | impl Datagram { | ------------- method in this implementation ... 58 | pub(crate) fn into_data(self) -> Vec<u8> { | ^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default ``` This commit hides `into_data` behind the `udp` feature as well.
A I altered the modified .github/workflows/check.yml
@@ -153,7 +153,13 @@ jobs:
if: success() || failure()
- name: Clippy
- run: cargo +${{ matrix.rust-toolchain }} clippy --all-targets -- -D warnings || ${{ matrix.rust-toolchain == 'nightly' }}
+ run: |
+ # Use cargo-hack to run clippy on each crate individually with its
+ # respective default features only. Can reveal warnings otherwise
+ # hidden given that a plain cargo clippy combines all features of the
+ # workspace. See e.g. https://github.com/mozilla/neqo/pull/1695.
+ cargo +${{ matrix.rust-toolchain }} install cargo-hack
+ cargo +${{ matrix.rust-toolchain }} hack clippy --all-targets -- -D warnings || ${{ matrix.rust-toolchain == 'nightly' }} I have pushed this commit in front of the original fix. The first commit (CI change only) now fails as expected. See e.g. https://github.com/mozilla/neqo/actions/runs/8101846886/job/22143006404. With the second commit (the actual fix) CI is green. (Well one of them failed unrelated on the @larseggert let me know what you think. |
@@ -54,6 +54,7 @@ impl Datagram { | |||
self.ttl | |||
} | |||
|
|||
#[cfg(feature = "udp")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this warning be generated if we added impl From<Datagram> for Vec<u8>
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently Datagram::into_data
is pub(crate)
as it is only used within neqo-common
, more specifically the neqo_common::udp
module. Replacing Datagram::into_data
with impl From<Datagram> for Vec<u8>
would make the functionality pub
. All pub
crate items are assumed to be used. Thus the warning would be gone, yes.
I suggest not exposing it as pub
, as that exposes the internal data representation of Datagram
, i.e. exposes that conversion to Vec<u8>
is cheap / reasonable. This is not a strong opinion. Happy to go with whatever you prefer.
(Tangentially, we might want to reconsider the data representation of Datagram
as part of #1693.)
Datagram::into_data
is used inneqo_common::udp
only.neqo_common::udp
is behind theudp
feature. The feature is not part of the crate's default features. Thus a plaincargo check
rightly complains with:This commit hides
into_data
behind theudp
feature as well.Introduced in #1604. My bad.