From c523d9495428de0c62c13b47259004a05d6839a3 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 4 Oct 2023 14:36:19 +0200 Subject: [PATCH] Bump to edition 2021 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since our MSRV is 1.61, this won’t change anything because this edition got made stable in 1.56. --- Cargo.toml | 3 +-- fuzz-afl/src/reproduce_decode.rs | 2 +- src/decoder.rs | 1 - src/idct.rs | 4 ++-- src/worker/immediate.rs | 1 - src/worker/rayon.rs | 2 -- tests/common/mod.rs | 2 +- tests/reftest/mod.rs | 2 +- 8 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8037f9bc..cb8a5f9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,7 @@ [package] name = "jpeg-decoder" version = "0.3.0" -edition = "2018" -resolver = "2" +edition = "2021" rust-version = "1.61.0" diff --git a/fuzz-afl/src/reproduce_decode.rs b/fuzz-afl/src/reproduce_decode.rs index 572fdf38..14cc9c8f 100644 --- a/fuzz-afl/src/reproduce_decode.rs +++ b/fuzz-afl/src/reproduce_decode.rs @@ -12,6 +12,6 @@ fn main() { let data = utils::read_file_from_args(); match decode(&data) { Ok(bytes) => println!("Decoded {} bytes", bytes.len()), - Err(e) => println!("Decoder returned an error: {:?}\nNote: Not a panic, this is fine.", e), + Err(e) => println!("Decoder returned an error: {e:?}\nNote: Not a panic, this is fine."), }; } diff --git a/src/decoder.rs b/src/decoder.rs index e4fa5f64..d7a7cd1e 100644 --- a/src/decoder.rs +++ b/src/decoder.rs @@ -16,7 +16,6 @@ use alloc::{format, vec}; use core::cmp; use core::mem; use core::ops::Range; -use std::convert::TryInto; use std::io::Read; pub const MAX_COMPONENTS: usize = 4; diff --git a/src/idct.rs b/src/idct.rs index 99f10ffa..20b57075 100644 --- a/src/idct.rs +++ b/src/idct.rs @@ -9,7 +9,7 @@ #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] use crate::parser::Dimensions; -use core::{convert::TryFrom, num::Wrapping}; +use core::num::Wrapping; pub(crate) fn choose_idct_size(full_size: Dimensions, requested_size: Dimensions) -> usize { fn scaled(len: u16, scale: usize) -> u16 { @@ -234,7 +234,7 @@ pub(crate) fn dequantize_and_idct_block( output_linestride, output, ), - _ => panic!("Unsupported IDCT scale {}/8", scale), + _ => panic!("Unsupported IDCT scale {scale}/8"), } } diff --git a/src/worker/immediate.rs b/src/worker/immediate.rs index 8c6e7dbd..64d22efe 100644 --- a/src/worker/immediate.rs +++ b/src/worker/immediate.rs @@ -1,7 +1,6 @@ use alloc::vec; use alloc::vec::Vec; use core::mem; -use core::convert::TryInto; use crate::decoder::MAX_COMPONENTS; use crate::error::Result; use crate::idct::dequantize_and_idct_block; diff --git a/src/worker/rayon.rs b/src/worker/rayon.rs index ec7df258..9a9656b9 100644 --- a/src/worker/rayon.rs +++ b/src/worker/rayon.rs @@ -1,5 +1,3 @@ -use core::convert::TryInto; - use rayon::iter::{IndexedParallelIterator, ParallelIterator}; use rayon::slice::ParallelSliceMut; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 2f64cb2f..ee91be48 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -28,7 +28,7 @@ pub fn test_files(test_dir: &Path) -> Vec { let path = test_dir.join(Path::new(&line)); if !test_files.contains(&path) { - panic!("The file {:?} specified in {:?} could not be found among the files being tested", line, test_dir.join("disabled.txt")); + panic!("The file {line:?} specified in {:?} could not be found among the files being tested", test_dir.join("disabled.txt")); } let position = test_files.iter().position(|p| p == &path).unwrap(); diff --git a/tests/reftest/mod.rs b/tests/reftest/mod.rs index 9b2eeab0..d443b587 100644 --- a/tests/reftest/mod.rs +++ b/tests/reftest/mod.rs @@ -116,7 +116,7 @@ fn reftest_decoder(mut decoder: jpeg::Decoder, path: &Path, encoder.set_color(ref_pixel_format); encoder.write_header().expect("png failed to write header").write_image_data(&pixels).expect("png failed to write data"); - panic!("decoding difference: {:?}, maximum difference was {}", output_path, max_diff); + panic!("decoding difference: {output_path:?}, maximum difference was {max_diff}"); } }