From 97dec32fa239a118712c36904f6a8d39bcac5200 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 7 Feb 2023 20:32:43 +0000 Subject: [PATCH] Fix all the clippy lints --- agb-fixnum/src/lib.rs | 10 +++++----- agb-image-converter/src/colour.rs | 3 +-- agb-image-converter/src/config.rs | 2 +- agb-image-converter/src/lib.rs | 2 +- agb-macros/src/lib.rs | 2 +- agb-sound-converter/src/lib.rs | 2 +- book/src/pong/01_introduction.md | 2 +- examples/the-hat-chooses-the-wizard/build.rs | 2 +- tools/src/main.rs | 2 +- 9 files changed, 13 insertions(+), 14 deletions(-) diff --git a/agb-fixnum/src/lib.rs b/agb-fixnum/src/lib.rs index 43ad8698..c56de948 100644 --- a/agb-fixnum/src/lib.rs +++ b/agb-fixnum/src/lib.rs @@ -545,7 +545,7 @@ impl Display for Num { fractional = (I::one() << N) - fractional; } - write!(f, "{}", integral)?; + write!(f, "{integral}")?; if fractional != I::zero() { write!(f, ".")?; @@ -1046,7 +1046,7 @@ mod tests { fn formats_whole_numbers_correctly() { let a = Num::::new(-4i32); - assert_eq!(format!("{}", a), "-4"); + assert_eq!(format!("{a}"), "-4"); } #[test] @@ -1060,9 +1060,9 @@ mod tests { let d: Num = minus_one / four; assert_eq!(b + c, 0.into()); - assert_eq!(format!("{}", b), "1.25"); - assert_eq!(format!("{}", c), "-1.25"); - assert_eq!(format!("{}", d), "-0.25"); + assert_eq!(format!("{b}"), "1.25"); + assert_eq!(format!("{c}"), "-1.25"); + assert_eq!(format!("{d}"), "-0.25"); } #[test] diff --git a/agb-image-converter/src/colour.rs b/agb-image-converter/src/colour.rs index b401b9bd..e607cadd 100644 --- a/agb-image-converter/src/colour.rs +++ b/agb-image-converter/src/colour.rs @@ -29,8 +29,7 @@ impl FromStr for Colour { fn from_str(colour: &str) -> Result { if colour.len() != 6 { return Err(format!( - "Expected colour to be 6 characters, got {}", - colour + "Expected colour to be 6 characters, got {colour}" )); } diff --git a/agb-image-converter/src/config.rs b/agb-image-converter/src/config.rs index 826b9e67..bdc498e0 100644 --- a/agb-image-converter/src/config.rs +++ b/agb-image-converter/src/config.rs @@ -6,7 +6,7 @@ use crate::{Colour, Colours, TileSize}; pub(crate) fn parse(filename: &str) -> Box { let config_toml = - fs::read_to_string(filename).unwrap_or_else(|_| panic!("Failed to read file {}", filename)); + fs::read_to_string(filename).unwrap_or_else(|_| panic!("Failed to read file {filename}")); let config: ConfigV1 = toml::from_str(&config_toml).expect("Failed to parse file"); diff --git a/agb-image-converter/src/lib.rs b/agb-image-converter/src/lib.rs index a6472f50..03800d53 100644 --- a/agb-image-converter/src/lib.rs +++ b/agb-image-converter/src/lib.rs @@ -236,7 +236,7 @@ pub fn include_aseprite_inner(input: TokenStream) -> TokenStream { let direction = tag.animation_direction() as usize; let name = tag.name(); - assert!(start <= end, "Tag {} has start > end", name); + assert!(start <= end, "Tag {name} has start > end"); quote! { (#name, Tag::new(SPRITES, #start, #end, #direction)) diff --git a/agb-macros/src/lib.rs b/agb-macros/src/lib.rs index a0f5f7c1..b567393d 100644 --- a/agb-macros/src/lib.rs +++ b/agb-macros/src/lib.rs @@ -116,7 +116,7 @@ pub fn num(input: TokenStream) -> TokenStream { fn hashed_ident(f: &T) -> Ident { let hash = calculate_hash(f); - Ident::new(&format!("_agb_main_func_{}", hash), Span::call_site()) + Ident::new(&format!("_agb_main_func_{hash}"), Span::call_site()) } fn calculate_hash(t: &T) -> u64 { diff --git a/agb-sound-converter/src/lib.rs b/agb-sound-converter/src/lib.rs index 5cbc2446..899729b1 100644 --- a/agb-sound-converter/src/lib.rs +++ b/agb-sound-converter/src/lib.rs @@ -26,7 +26,7 @@ pub fn include_wav(input: TokenStream) -> TokenStream { let include_path = path.to_string_lossy(); let wav_reader = hound::WavReader::open(&path) - .unwrap_or_else(|_| panic!("Failed to load file {}", include_path)); + .unwrap_or_else(|_| panic!("Failed to load file {include_path}")); let samples: Vec = samples_from_reader(wav_reader).collect(); let samples = ByteString(&samples); diff --git a/book/src/pong/01_introduction.md b/book/src/pong/01_introduction.md index 08ce3fcc..ed272238 100644 --- a/book/src/pong/01_introduction.md +++ b/book/src/pong/01_introduction.md @@ -26,7 +26,7 @@ Then replace the `name` field in `Cargo.toml` with `pong`, to end up with someth name = "pong" version = "0.1.0" authors = ["Your name here"] -edition = "2018" +edition = "2021" # ... ``` diff --git a/examples/the-hat-chooses-the-wizard/build.rs b/examples/the-hat-chooses-the-wizard/build.rs index 21e30dd2..528b7d3f 100644 --- a/examples/the-hat-chooses-the-wizard/build.rs +++ b/examples/the-hat-chooses-the-wizard/build.rs @@ -118,7 +118,7 @@ mod tiled_export { "Slime Spawn" => slimes.push((x, y)), "Player Start" => player_start = Some((x, y)), "Enemy Stop" => enemy_stops.push((x, y)), - _ => panic!("Unknown object type {}", object_type), + _ => panic!("Unknown object type {object_type}"), } } diff --git a/tools/src/main.rs b/tools/src/main.rs index 79118229..999797b2 100644 --- a/tools/src/main.rs +++ b/tools/src/main.rs @@ -35,7 +35,7 @@ fn main() { }; if let Err(e) = result { - eprintln!("Error: {:?}", e); + eprintln!("Error: {e:?}"); } }