Skip to content

Commit

Permalink
fix: feature flag Datagram::into_data (#1695)
Browse files Browse the repository at this point in the history
* feat(.github): run cargo clippy on each crate individually

> 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. #1695.

* fix: feature flag Datagram::into_data

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

* Install cargo-hack as part of 'Install Rust tools'
  • Loading branch information
mxinden authored Mar 5, 2024
1 parent 78919a5 commit d56e993
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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")]
#[must_use]
pub(crate) fn into_data(self) -> Vec<u8> {
self.d
Expand Down

0 comments on commit d56e993

Please sign in to comment.