Skip to content

Commit

Permalink
Fix Rust 1.59 lints (#1600)
Browse files Browse the repository at this point in the history
* fix 1.59 lints
* also run lints on rust beta
* fix duplicated code lint
  • Loading branch information
luizirber authored Jun 17, 2021
1 parent b787b75 commit a2d438d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/core/src/ffi/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ thread_local! {
pub static LAST_ERROR: RefCell<Option<Error>> = RefCell::new(None);
}

#[allow(clippy::clippy::wrong_self_convention)]
#[allow(clippy::wrong_self_convention)]
pub trait ForeignObject: Sized {
type RustObject;

Expand Down
23 changes: 10 additions & 13 deletions src/core/src/sketch/nodegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,19 @@ impl Nodegraph {
let byte_size = tablesize / 8 + 1;

let rem = byte_size % 4;
let blocks: Vec<u32> = if rem == 0 {
let blocks: Vec<u32> = {
let mut blocks = vec![0; byte_size / 4];
rdr.read_u32_into::<LittleEndian>(&mut blocks)?;
blocks
} else {
let mut blocks = vec![0; byte_size / 4];
rdr.read_u32_into::<LittleEndian>(&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
};

Expand Down

0 comments on commit a2d438d

Please sign in to comment.