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 all 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
2 changes: 1 addition & 1 deletion .github/actions/rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ runs:

- name: Install Rust tools
shell: bash
run: cargo +${{ inputs.version }} binstall --no-confirm cargo-llvm-cov cargo-nextest flamegraph
run: cargo +${{ inputs.version }} binstall --no-confirm cargo-llvm-cov cargo-nextest flamegraph cargo-hack

- name: Use Rust cache
uses: Swatinem/rust-cache@v2
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,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