Skip to content

Commit

Permalink
Fix and un-allow clippy::unseparated_literal_suffix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys committed Dec 18, 2024
1 parent 1fad7ba commit 9090a9b
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 28 deletions.
1 change: 0 additions & 1 deletion examples/scenes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions examples/scenes/src/simple_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions examples/scenes/src/test_scenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down Expand Up @@ -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()),
);
}

Expand All @@ -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,
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion vello_encoding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions vello_encoding/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -156,22 +156,22 @@ 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);
}

#[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);
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion vello_encoding/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion vello_encoding/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion vello_shaders/src/cpu/draw_leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down
4 changes: 2 additions & 2 deletions vello_shaders/src/cpu/euler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions vello_shaders/src/cpu/fine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 0 additions & 1 deletion vello_shaders/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)]

Expand Down

0 comments on commit 9090a9b

Please sign in to comment.