From 9090a9ba1d7e5f8e567045c88a64b5780a5e2f91 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 18 Dec 2024 08:46:55 -0500 Subject: [PATCH] Fix and un-allow `clippy::unseparated_literal_suffix` lints --- examples/scenes/src/lib.rs | 1 - examples/scenes/src/simple_text.rs | 4 ++-- examples/scenes/src/test_scenes.rs | 20 ++++++++++---------- vello_encoding/src/lib.rs | 1 - vello_encoding/src/math.rs | 12 ++++++------ vello_encoding/src/path.rs | 2 +- vello_encoding/src/resolve.rs | 2 +- vello_shaders/src/cpu/draw_leaf.rs | 2 +- vello_shaders/src/cpu/euler.rs | 4 ++-- vello_shaders/src/cpu/fine.rs | 4 ++-- vello_shaders/src/lib.rs | 1 - 11 files changed, 25 insertions(+), 28 deletions(-) diff --git a/examples/scenes/src/lib.rs b/examples/scenes/src/lib.rs index 9daf102eb..1631bc74f 100644 --- a/examples/scenes/src/lib.rs +++ b/examples/scenes/src/lib.rs @@ -12,7 +12,6 @@ unreachable_pub, missing_docs, clippy::wildcard_imports, - clippy::unseparated_literal_suffix, clippy::cast_possible_truncation, clippy::shadow_unrelated, clippy::missing_panics_doc, diff --git a/examples/scenes/src/simple_text.rs b/examples/scenes/src/simple_text.rs index bff6258e5..09587143c 100644 --- a/examples/scenes/src/simple_text.rs +++ b/examples/scenes/src/simple_text.rs @@ -150,8 +150,8 @@ impl SimpleText { let metrics = font_ref.metrics(font_size, &var_loc); let line_height = metrics.ascent - metrics.descent + metrics.leading; let glyph_metrics = font_ref.glyph_metrics(font_size, &var_loc); - let mut pen_x = 0f32; - let mut pen_y = 0f32; + let mut pen_x = 0_f32; + let mut pen_y = 0_f32; scene .draw_glyphs(font) .font_size(size) diff --git a/examples/scenes/src/test_scenes.rs b/examples/scenes/src/test_scenes.rs index a47768183..c8e6b2cff 100644 --- a/examples/scenes/src/test_scenes.rs +++ b/examples/scenes/src/test_scenes.rs @@ -695,7 +695,7 @@ mod impls { palette::css::WHITE, Affine::translate((110.0, 700.0)), // Add a skew to simulate an oblique font. - Some(Affine::skew(20f64.to_radians().tan(), 0.0)), + Some(Affine::skew(20_f64.to_radians().tan(), 0.0)), &Stroke::new(1.0), s, ); @@ -766,7 +766,7 @@ mod impls { ); scene.draw_image( &piet_logo, - Affine::translate((800.0, 50.0)) * Affine::rotate(20f64.to_radians()), + Affine::translate((800.0, 50.0)) * Affine::rotate(20_f64.to_radians()), ); } @@ -779,7 +779,7 @@ mod impls { ]); scene.fill( Fill::NonZero, - Affine::rotate(25f64.to_radians()) * Affine::scale_non_uniform(2.0, 1.0), + Affine::rotate(25_f64.to_radians()) * Affine::scale_non_uniform(2.0, 1.0), &Gradient::new_radial((200.0, 200.0), 80.0).with_stops([ palette::css::RED, palette::css::GREEN, @@ -812,8 +812,8 @@ mod impls { } pub(super) fn square(scene: &mut Scene, kind: Kind, transform: Affine, extend: Extend) { let colors = [palette::css::RED, palette::css::LIME, palette::css::BLUE]; - let width = 300f64; - let height = 300f64; + let width = 300_f64; + let height = 300_f64; let gradient: Brush = match kind { Kind::Linear => { Gradient::new_linear((width * 0.35, height * 0.5), (width * 0.65, height * 0.5)) @@ -831,8 +831,8 @@ mod impls { } Kind::Sweep => Gradient::new_sweep( (width * 0.5, height * 0.5), - 30f32.to_radians(), - 150f32.to_radians(), + 30_f32.to_radians(), + 150_f32.to_radians(), ) .with_stops(colors) .with_extend(extend) @@ -888,8 +888,8 @@ mod impls { palette::css::YELLOW, Color::from_rgba8(6, 85, 186, 255), ]; - let width = 400f64; - let height = 200f64; + let width = 400_f64; + let height = 200_f64; let rect = Rect::new(0.0, 0.0, width, height); scene.fill(Fill::NonZero, transform, palette::css::WHITE, None, &rect); scene.fill( @@ -1715,7 +1715,7 @@ mod impls { // Skewed affine transformation. scene.draw_blurred_rounded_rect( - Affine::translate((900.0, 300.0)) * Affine::skew(20f64.to_radians().tan(), 0.0), + Affine::translate((900.0, 300.0)) * Affine::skew(20_f64.to_radians().tan(), 0.0), rect, palette::css::BLACK, radius, diff --git a/vello_encoding/src/lib.rs b/vello_encoding/src/lib.rs index eb78296ed..af919786b 100644 --- a/vello_encoding/src/lib.rs +++ b/vello_encoding/src/lib.rs @@ -22,7 +22,6 @@ missing_debug_implementations, single_use_lifetimes, clippy::return_self_not_must_use, - clippy::unseparated_literal_suffix, clippy::cast_possible_truncation, clippy::missing_assert_message, clippy::missing_panics_doc, diff --git a/vello_encoding/src/math.rs b/vello_encoding/src/math.rs index 8989698af..48c44cd04 100644 --- a/vello_encoding/src/math.rs +++ b/vello_encoding/src/math.rs @@ -87,8 +87,8 @@ pub(crate) fn f32_to_f16(val: f32) -> u16 { const INF_32: u32 = 255 << 23; const INF_16: u32 = 31 << 23; const MAGIC: u32 = 15 << 23; - const SIGN_MASK: u32 = 0x8000_0000u32; - const ROUND_MASK: u32 = !0xFFFu32; + const SIGN_MASK: u32 = 0x8000_0000_u32; + const ROUND_MASK: u32 = !0xFFF_u32; let u = val.to_bits(); let sign = u & SIGN_MASK; @@ -156,14 +156,14 @@ mod tests { fn test_f32_to_f16_simple() { let input: f32 = std::f32::consts::PI; let output: u16 = f32_to_f16(input); - assert_eq!(0x4248u16, output); // 3.141 + assert_eq!(0x4248_u16, output); // 3.141 } #[test] fn test_f32_to_f16_nan_overflow() { // A signaling NaN with unset high bits but a low bit that could get accidentally masked // should get converted to a quiet NaN and not infinity. - let input: f32 = f32::from_bits(0x7F800001u32); + let input: f32 = f32::from_bits(0x7F800001_u32); assert!(input.is_nan()); let output: u16 = f32_to_f16(input); assert_eq!(0x7E00, output); @@ -171,7 +171,7 @@ mod tests { #[test] fn test_f32_to_f16_inf() { - let input: f32 = f32::from_bits(0x7F800000u32); + let input: f32 = f32::from_bits(0x7F800000_u32); assert!(input.is_infinite()); let output: u16 = f32_to_f16(input); assert_eq!(0x7C00, output); @@ -200,7 +200,7 @@ mod tests { #[test] fn test_f16_to_f32_simple() { - let input: u16 = 0x4248u16; + let input: u16 = 0x4248_u16; let output: f32 = f16_to_f32(input); assert_eq!(3.140625, output); } diff --git a/vello_encoding/src/path.rs b/vello_encoding/src/path.rs index f2855535f..a1703ce0d 100644 --- a/vello_encoding/src/path.rs +++ b/vello_encoding/src/path.rs @@ -603,7 +603,7 @@ impl<'a> PathEncoder<'a> { /// Encodes an empty path (as placeholder for begin clip). pub(crate) fn empty_path(&mut self) { - let coords = [0.0f32, 0., 0., 0.]; + let coords = [0.0_f32, 0., 0., 0.]; let bytes = bytemuck::bytes_of(&coords); self.data.extend_from_slice(bytes); self.tags.push(PathTag::LINE_TO_F32); diff --git a/vello_encoding/src/resolve.rs b/vello_encoding/src/resolve.rs index ee8248a80..44c03e3ff 100644 --- a/vello_encoding/src/resolve.rs +++ b/vello_encoding/src/resolve.rs @@ -293,7 +293,7 @@ impl Resolver { // In this case, let's zero out the dimensions so we don't attempt to render // anything. // TODO: a better strategy: texture array? downsample large images? - data.extend_from_slice(&[0u8; 8]); + data.extend_from_slice(&[0_u8; 8]); pos = *draw_data_offset + 8; } } diff --git a/vello_shaders/src/cpu/draw_leaf.rs b/vello_shaders/src/cpu/draw_leaf.rs index 7c772b81f..56ddfcce4 100644 --- a/vello_shaders/src/cpu/draw_leaf.rs +++ b/vello_shaders/src/cpu/draw_leaf.rs @@ -76,7 +76,7 @@ fn draw_leaf_main( info[di + 3] = f32::to_bits(line_c); } DrawTag::RADIAL_GRADIENT => { - const GRADIENT_EPSILON: f32 = 1.0f32 / (1 << 12) as f32; + const GRADIENT_EPSILON: f32 = 1.0_f32 / (1 << 12) as f32; info[di] = draw_flags; let mut p0 = Vec2::new( f32::from_bits(scene[dd as usize + 1]), diff --git a/vello_shaders/src/cpu/euler.rs b/vello_shaders/src/cpu/euler.rs index ddf0bc7d0..5c4050a19 100644 --- a/vello_shaders/src/cpu/euler.rs +++ b/vello_shaders/src/cpu/euler.rs @@ -303,7 +303,7 @@ pub(crate) fn espc_int_approx(x: f32) -> f32 { let a = if y < BREAK1 { (SIN_SCALE * y).sin() * (1.0 / SIN_SCALE) } else if y < BREAK2 { - (8.0f32.sqrt() / 3.0) * (y - 1.0) * (y - 1.0).abs().sqrt() + FRAC_PI_4 + (8.0_f32.sqrt() / 3.0) * (y - 1.0) * (y - 1.0).abs().sqrt() + FRAC_PI_4 } else { let (a, b, c) = if y < BREAK3 { (QUAD_A1, QUAD_B1, QUAD_C1) @@ -322,7 +322,7 @@ pub(crate) fn espc_int_inv_approx(x: f32) -> f32 { } else if y < 0.903249293595206 { let b = y - FRAC_PI_4; let u = b.abs().powf(2. / 3.).copysign(b); - u * (9.0f32 / 8.).cbrt() + 1.0 + u * (9.0_f32 / 8.).cbrt() + 1.0 } else { let (u, v, w) = if y < 2.038857793595206 { const B: f32 = 0.5 * QUAD_B1 / QUAD_A1; diff --git a/vello_shaders/src/cpu/fine.rs b/vello_shaders/src/cpu/fine.rs index 3b6bd3b5b..81669dd61 100644 --- a/vello_shaders/src/cpu/fine.rs +++ b/vello_shaders/src/cpu/fine.rs @@ -122,8 +122,8 @@ fn fine_main( let width_in_tiles = config.width_in_tiles; let height_in_tiles = config.height_in_tiles; let n_tiles = width_in_tiles * height_in_tiles; - let mut area = vec![0.0f32; TILE_SIZE]; - let mut rgba = vec![[0.0f32; 4]; TILE_SIZE]; + let mut area = vec![0.0_f32; TILE_SIZE]; + let mut rgba = vec![[0.0_f32; 4]; TILE_SIZE]; for tile_ix in 0..n_tiles { for x in &mut rgba { *x = [0.0; 4]; diff --git a/vello_shaders/src/lib.rs b/vello_shaders/src/lib.rs index 7f3babac8..8d42c5730 100644 --- a/vello_shaders/src/lib.rs +++ b/vello_shaders/src/lib.rs @@ -48,7 +48,6 @@ clippy::print_stdout, clippy::shadow_unrelated, clippy::todo, - clippy::unseparated_literal_suffix, reason = "Deferred, only apply in some feature sets so not expect" )]