From a2d438dc9967e05d0e8919e1b180a5ea6636f5ef Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Thu, 17 Jun 2021 23:32:31 +0000 Subject: [PATCH] Fix Rust 1.59 lints (#1600) * fix 1.59 lints * also run lints on rust beta * fix duplicated code lint --- .github/workflows/rust.yml | 13 +++++++++++-- src/core/src/ffi/utils.rs | 2 +- src/core/src/sketch/nodegraph.rs | 23 ++++++++++------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fd84cdc3ab..aec8581e10 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -136,15 +136,24 @@ jobs: lints: name: Lints runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + build: [beta, stable] + include: + - build: beta + rust: beta + - build: stable + rust: stable steps: - name: Checkout sources uses: actions/checkout@v1 - - name: Install stable toolchain + - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: stable + toolchain: ${{ matrix.rust }} override: true components: rustfmt, clippy diff --git a/src/core/src/ffi/utils.rs b/src/core/src/ffi/utils.rs index 69baac7b88..04652cbeef 100644 --- a/src/core/src/ffi/utils.rs +++ b/src/core/src/ffi/utils.rs @@ -18,7 +18,7 @@ thread_local! { pub static LAST_ERROR: RefCell> = RefCell::new(None); } -#[allow(clippy::clippy::wrong_self_convention)] +#[allow(clippy::wrong_self_convention)] pub trait ForeignObject: Sized { type RustObject; diff --git a/src/core/src/sketch/nodegraph.rs b/src/core/src/sketch/nodegraph.rs index 37c89fb4cf..b599f0e73c 100644 --- a/src/core/src/sketch/nodegraph.rs +++ b/src/core/src/sketch/nodegraph.rs @@ -241,22 +241,19 @@ impl Nodegraph { let byte_size = tablesize / 8 + 1; let rem = byte_size % 4; - let blocks: Vec = if rem == 0 { + let blocks: Vec = { let mut blocks = vec![0; byte_size / 4]; rdr.read_u32_into::(&mut blocks)?; - blocks - } else { - let mut blocks = vec![0; byte_size / 4]; - rdr.read_u32_into::(&mut blocks)?; - - let mut values = [0u8; 4]; - for item in values.iter_mut().take(rem) { - let byte = rdr.read_u8().expect("error reading bins"); - *item = byte; + if rem != 0 { + let mut values = [0u8; 4]; + for item in values.iter_mut().take(rem) { + let byte = rdr.read_u8().expect("error reading bins"); + *item = byte; + } + let mut block = vec![0u32; 1]; + LittleEndian::read_u32_into(&values, &mut block); + blocks.push(block[0]); } - let mut block = vec![0u32; 1]; - LittleEndian::read_u32_into(&values, &mut block); - blocks.push(block[0]); blocks };