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

fix: feature flag Datagram::into_data #1695

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
uses: ilammy/msvc-dev-cmd@v1

- name: Install Rust tools
run: cargo +${{ matrix.rust-toolchain }} binstall --no-confirm cargo-llvm-cov cargo-nextest
run: cargo +${{ matrix.rust-toolchain }} binstall --no-confirm cargo-llvm-cov cargo-nextest cargo-hack

# This step might be removed if the distro included a recent enough
# version of NSS. Ubuntu 20.04 only has 3.49, which is far too old.
Expand Down Expand Up @@ -153,7 +153,12 @@ 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 }} hack clippy --all-targets -- -D warnings || ${{ matrix.rust-toolchain == 'nightly' }}
if: success() || failure()

- name: Check rustdoc links
Expand Down
1 change: 1 addition & 0 deletions neqo-common/src/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl Datagram {
self.ttl
}

#[cfg(feature = "udp")]
Copy link
Member

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?

Copy link
Collaborator Author

@mxinden mxinden Mar 1, 2024

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.)

#[must_use]
pub(crate) fn into_data(self) -> Vec<u8> {
self.d
Expand Down