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 a few lints introducedin Rust 1.77 #348

Merged
merged 19 commits into from
Apr 1, 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
65 changes: 34 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -65,7 +65,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -80,7 +80,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@stable
- name: Install doxygen 1.9.5
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
test: false
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -137,9 +137,9 @@ jobs:
- name: Create FFI modules DIR
run: mkdir ffi-modules\${{ matrix.target }}
- name: Build FFI
run: cargo build -p dnp3-ffi --release --target ${{ matrix.target }} --message-format json | Out-File -encoding "UTF8" .\ffi-modules\${{ matrix.target }}\build.jni.log
run: cargo build -p dnp3-ffi --release --target ${{ matrix.target }}
- name: Build JNI
run: cargo build -p dnp3-ffi-java --release --target ${{ matrix.target }} --message-format json | Out-File -encoding "UTF8" .\ffi-modules\${{ matrix.target }}\build.jni.log
run: cargo build -p dnp3-ffi-java --release --target ${{ matrix.target }}
- name: Copy the FFI and JNI libs
shell: pwsh
run: |
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
- x86_64-apple-darwin # 64-bit macOS (10.7+, Lion+)
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Caching
Expand All @@ -179,9 +179,9 @@ jobs:
- name: Create FFI modules dir
run: mkdir -p ffi-modules/${{ matrix.target }}
- name: Build FFI
run: cargo build -p dnp3-ffi --release --message-format json > ffi-modules/${{ matrix.target }}/build.ffi.log
run: cargo build -p dnp3-ffi --release
- name: Build JNI
run: cargo build -p dnp3-ffi-java --release --message-format json > ffi-modules/${{ matrix.target }}/build.jni.log
run: cargo build -p dnp3-ffi-java --release
- name: Copy the FFI and JNI libs
run: |
cp ./target/release/libdnp3_ffi.dylib ./ffi-modules/${{ matrix.target }}
Expand Down Expand Up @@ -218,7 +218,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -231,9 +231,9 @@ jobs:
- name: Create FFI modules dir
run: mkdir -p ffi-modules/${{ matrix.target }}
- name: Build FFI
run: cross build -p dnp3-ffi --release --target ${{ matrix.target }} --message-format json > ffi-modules/${{ matrix.target }}/build.ffi.log
run: cross build -p dnp3-ffi --release --target ${{ matrix.target }}
- name: Build JNI
run: cross build -p dnp3-ffi-java --release --target ${{ matrix.target }} --message-format json > ffi-modules/${{ matrix.target }}/build.jni.log
run: cross build -p dnp3-ffi-java --release --target ${{ matrix.target }}
- name: Copy the FFI and JNI libs
run: |
cp ./target/${{ matrix.target }}/release/libdnp3_ffi.so ./ffi-modules/${{ matrix.target }}
Expand All @@ -247,7 +247,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install dependencies
working-directory: guide
run: yarn install
Expand All @@ -269,35 +269,38 @@ jobs:
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Cargo CycloneDx
run: cargo install cargo-cyclonedx
- name: Install custom allow-list tool
run: cargo install --git https://github.com/stepfunc/bom-tools.git
- name: Caching
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Swatinem/rust-cache@v2
- name: Checkout BOM tools repo
uses: actions/checkout@v3
with:
repository: stepfunc/bom-tools
ref: 0.1.0
path: bom-tools
- name: Install BOM tools
working-directory: bom-tools
run: cargo install --path bom-tools
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Download compiled FFI
uses: actions/download-artifact@v3
with:
name: ffi-modules
path: ffi-modules
- name: Create SBOMs
run: |
for dir in ffi-modules/*; do
target=`basename "${dir}"`
cargo cyclonedx -f json --target $target
mv ./ffi/dnp3-ffi/dnp3-ffi.cdx.json ffi-modules/$target
mv ./ffi/dnp3-ffi-java/dnp3-ffi-java.cdx.json ffi-modules/$target
done
- name: Create FFI third-party-licenses.txt
run: bom-tools gen-licenses-dir ./ffi-modules build.ffi.log ./dep_config.json > third-party-licenses.txt
run: allow-list gen-licenses-dir -l ffi-modules -b dnp3-ffi.cdx.json -c dep_config.json > third-party-licenses.txt
- name: Create FFI third-party-licenses-java.txt
run: allow-list gen-licenses-dir -l ffi-modules -b dnp3-ffi-java.cdx.json -c dep_config.json > third-party-licenses-java.txt
- name: Package C/C++ bindings
run: cargo run --bin dnp3-bindings -- --c --package ./ffi-modules --options ./packaging.json -f third-party-licenses.txt
- name: Package .NET bindings
run: cargo run --bin dnp3-bindings -- --dotnet --package ./ffi-modules --options ./packaging.json -f third-party-licenses.txt
- name: Create JNI third-party-licenses.txt
run: bom-tools gen-licenses-dir ./ffi-modules build.jni.log ./dep_config.json > third-party-licenses.txt
- name: Package Java bindings
run: cargo run --bin dnp3-bindings -- --java --package ./ffi-modules --options ./packaging.json -f third-party-licenses.txt
run: cargo run --bin dnp3-bindings -- --java --package ./ffi-modules --options ./packaging.json -f third-party-licenses-java.txt
- name: Upload C/C++ bindings
uses: actions/upload-artifact@v3
with:
Expand All @@ -323,7 +326,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Caching
Expand All @@ -337,7 +340,7 @@ jobs:
shell: bash
run: (cd ffi/bindings/java/dnp3 && sudo mvn install)
- name: Checkout dnp4s
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: stepfunc/dnp4s
ssh-key: ${{ secrets.DNP4S_SSH_KEY }}
Expand Down Expand Up @@ -372,7 +375,7 @@ jobs:
cd ../conformance-results
zip -r ../../release/conformance-results.zip .
- name: Checkout stepfunc/docs
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: stepfunc/docs
ssh-key: ${{ secrets.SFIO_DOCS_SSH_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions dep_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,23 @@
}
]
},
"getrandom": {
"id": "getrandom",
"source": "crates.io",
"authors": null,
"licenses": [
{
"MIT": {
"copyright": {
"Lines": [
"Copyright (c) 2018-2024 The rust-random Project Developers",
"Copyright (c) 2014 The Rust Project Developers"
]
}
}
}
]
},
"hmac": {
"id": "hmac",
"source": "crates.io",
Expand Down
8 changes: 4 additions & 4 deletions dnp3/src/app/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ impl Display for BadAttribute {

pub(crate) enum AttrWriteError {
/// underlying cursor error
Cursor(WriteError),
Cursor,
/// attribute value could not be encoded
BadAttribute(BadAttribute),
}
Expand All @@ -1054,8 +1054,8 @@ impl From<BadAttribute> for AttrWriteError {
}

impl From<WriteError> for AttrWriteError {
fn from(err: WriteError) -> Self {
AttrWriteError::Cursor(err)
fn from(_: WriteError) -> Self {
AttrWriteError::Cursor
}
}

Expand Down Expand Up @@ -1472,7 +1472,7 @@ impl<'a> Attribute<'a> {
impl From<AttrWriteError> for TaskError {
fn from(value: AttrWriteError) -> Self {
match value {
AttrWriteError::Cursor(_) => TaskError::WriteError,
AttrWriteError::Cursor => TaskError::WriteError,
AttrWriteError::BadAttribute(x) => TaskError::BadEncoding(BadEncoding::Attribute(x)),
}
}
Expand Down
1 change: 0 additions & 1 deletion dnp3/src/app/extensions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::app::control::*;
use crate::app::measurement::Flags;
use crate::app::measurement::*;
use crate::app::{FunctionCode, QualifierCode};
use crate::util::bit::bits::{BIT_6, BIT_7};
Expand Down
4 changes: 0 additions & 4 deletions dnp3/src/app/parse/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ pub(crate) trait Index: Copy + Clone + FixedSize + PartialEq + Display {
fn next(self) -> Self;
fn widen_to_u16(self) -> u16;

fn is_zero(&self) -> bool {
*self == Self::zero()
}

fn one() -> Self {
Self::zero().next()
}
Expand Down
1 change: 0 additions & 1 deletion dnp3/src/app/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::time::{Duration, SystemTime};

use crate::app::measurement::DoubleBit;
Expand Down
1 change: 0 additions & 1 deletion dnp3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ patterns_in_fns_without_body,
pub_use_of_private_extern_crate,
unknown_crate_types,
order_dependent_trait_objects,
illegal_floating_point_literal_pattern,
improper_ctypes,
late_bound_lifetime_arguments,
non_camel_case_types,
Expand Down
2 changes: 1 addition & 1 deletion dnp3/src/link/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a> FrameData<'a> {
// this can all be statically verified not to panic since the buffer is a constant length
pub(crate) fn format_header_fixed_size(
header: Header,
buffer: &mut [u8; super::constant::LINK_HEADER_LENGTH],
buffer: &mut [u8; constant::LINK_HEADER_LENGTH],
) {
fn to_le(x: u16) -> (u8, u8) {
let low = (x & 0xFF) as u8;
Expand Down
4 changes: 2 additions & 2 deletions dnp3/src/link/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ enum ParseState {

pub(crate) struct FramePayload {
length: usize,
buffer: [u8; super::constant::MAX_FRAME_PAYLOAD_LENGTH],
buffer: [u8; constant::MAX_FRAME_PAYLOAD_LENGTH],
}

impl FramePayload {
pub(crate) fn new() -> Self {
Self {
length: 0,
buffer: [0; super::constant::MAX_FRAME_PAYLOAD_LENGTH],
buffer: [0; constant::MAX_FRAME_PAYLOAD_LENGTH],
}
}

Expand Down
2 changes: 1 addition & 1 deletion dnp3/src/master/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl std::fmt::Display for FileError {
FileError::NoPermission => f.write_str("no permission"),
FileError::BadBlockNum => f.write_str("bad block number"),
FileError::AbortByUser => f.write_str("aborted by user"),
FileError::TaskError(t) => std::fmt::Debug::fmt(&t, f),
FileError::TaskError(t) => Debug::fmt(&t, f),
FileError::MaxLengthExceeded => f.write_str("exceeded maximum received length"),
}
}
Expand Down
12 changes: 1 addition & 11 deletions dnp3/src/master/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::time::{Duration, SystemTime};

use crate::app::attr::*;
use crate::app::measurement::*;
use crate::app::variations::Variation;
use crate::app::*;

use crate::decode::DecodeLevel;
Expand Down Expand Up @@ -31,7 +30,7 @@ use crate::util::session::Enabled;
/// Handle to a master communication channel. This handle controls
/// a task running on the Tokio Runtime.
///
/// It provides a uniform API for all of the various types of communication channels supported
/// It provides a uniform API for all the various types of communication channels supported
/// by the library.
#[derive(Debug, Clone)]
pub struct MasterChannel {
Expand Down Expand Up @@ -461,10 +460,6 @@ pub trait AssociationInformation: Send + Sync {
fn unsolicited_response(&mut self, _is_duplicate: bool, _seq: Sequence) {}
}

pub(crate) struct NullAssociationInformation;

impl AssociationInformation for NullAssociationInformation {}

/// Information about the object header and specific variation
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct HeaderInfo {
Expand Down Expand Up @@ -645,8 +640,3 @@ pub(crate) fn handle_attribute(
}
}
}

/// read handler that does nothing
#[derive(Copy, Clone)]
pub(crate) struct NullReadHandler;
impl ReadHandler for NullReadHandler {}
Loading
Loading