From ea73bb40010d78bb415e617e26243b407747bf2a 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 | 4 ++-- 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, 21 insertions(+), 24 deletions(-) diff --git a/examples/scenes/src/lib.rs b/examples/scenes/src/lib.rs index b6870fe2a..f9d696849 100644 --- a/examples/scenes/src/lib.rs +++ b/examples/scenes/src/lib.rs @@ -13,7 +13,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 5fc93be25..c9e21da36 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 0d63945aa..6b108ecbe 100644 --- a/vello_encoding/src/lib.rs +++ b/vello_encoding/src/lib.rs @@ -23,7 +23,6 @@ elided_lifetimes_in_paths, 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..4c858ebfb 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; 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 0fa5bb2c8..2cb731325 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 54c063491..a6699720e 100644 --- a/vello_shaders/src/lib.rs +++ b/vello_shaders/src/lib.rs @@ -49,7 +49,6 @@ clippy::print_stdout, clippy::shadow_unrelated, clippy::todo, - clippy::unseparated_literal_suffix, reason = "Deferred, only apply in some feature sets so not expect" )]