Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed May 2, 2024
1 parent 8ba259e commit 5cb7571
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
14 changes: 4 additions & 10 deletions altium-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,7 @@ fn handle_field(
.remove("map")
.expect("missing 'map' attribute");

process_array(
&struct_ident,
&field_ident,
count_ident,
arr_map,
match_arms,
);
process_array(struct_ident, &field_ident, count_ident, arr_map, match_arms);
error_if_map_not_empty(&field_attr_map);
return;
} else if arr_val_str != "false" {
Expand Down Expand Up @@ -174,7 +168,7 @@ fn handle_field(
// Types `Location` and `LocationFract` are special cases
let is_location_fract = path_str.contains("LocationFract");
if is_location_fract || path_str.contains("Location") {
process_location(&struct_ident, &field_ident, is_location_fract, match_arms);
process_location(struct_ident, &field_ident, is_location_fract, match_arms);
return;
}

Expand All @@ -185,12 +179,12 @@ fn handle_field(
} = if path_str.contains("String") || path_str.contains("str") {
// Altium does this weird thing where it will create a normal key and a key
// with `%UTF8%` if a value is utf8. We need to discard those redundant values
make_utf8_handler(&match_pat, &field_ident, &struct_ident, &update_stmt)
make_utf8_handler(&match_pat, &field_ident, struct_ident, &update_stmt)
} else {
Utf8Handler::default()
};

let ctx_msg = make_ctx_message(&match_pat, &field_ident, &struct_ident);
let ctx_msg = make_ctx_message(&match_pat, &field_ident, struct_ident);

let quoted = quote! {
#utf8_arm
Expand Down
6 changes: 3 additions & 3 deletions altium/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ impl Rgb {

pub fn as_float_rgba(self) -> [f32; 4] {
[
self.r as f32 / 255.0,
self.g as f32 / 255.0,
self.b as f32 / 255.0,
f32::from(self.r) / 255.0,
f32::from(self.g) / 255.0,
f32::from(self.b) / 255.0,
1.0,
]
}
Expand Down
8 changes: 4 additions & 4 deletions altium/src/sch/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ impl SchPin {
// 6 bytes unknown
let (_unknown, rest) = buf
.split_first_chunk::<6>()
.ok_or_else(|| PinError::TooShort(buf.len(), "initial group"))?;
.ok_or(PinError::TooShort(buf.len(), "initial group"))?;

// 6 more bytes unknown - symbols
let (_unknown, rest) = rest
.split_first_chunk::<6>()
.ok_or_else(|| PinError::TooShort(rest.len(), "second group"))?;
.ok_or(PinError::TooShort(rest.len(), "second group"))?;

let (description, rest) = sized_buf_to_utf8(rest, "description")?;

// TODO: ty_info
let ([formal_type, _ty_info, rot_hide, l0, l1, x0, x1, y0, y1], rest) = rest
.split_first_chunk()
.ok_or_else(|| PinError::TooShort(rest.len(), "position extraction"))?;
.ok_or(PinError::TooShort(rest.len(), "position extraction"))?;

assert_eq!(
*formal_type, 1,
Expand All @@ -72,7 +72,7 @@ impl SchPin {

let (_unknown, rest) = rest
.split_first_chunk::<4>()
.ok_or_else(|| PinError::TooShort(rest.len(), "remaining buffer"))?;
.ok_or(PinError::TooShort(rest.len(), "remaining buffer"))?;

let (name, rest) = sized_buf_to_utf8(rest, "name")?;
let (designator, rest) = sized_buf_to_utf8(rest, "designator")?;
Expand Down
27 changes: 18 additions & 9 deletions ecadg/src/gfx/tessellated.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(dead_code, unused_imports)]
#![allow(clippy::similar_names)]

use std::mem;

use alt_to_lyon::ToLyonTy;
Expand Down Expand Up @@ -40,7 +42,7 @@ const FILL_OPTIONS: FillOptions = FillOptions::DEFAULT.with_tolerance(TOLERANCE)
// const DEFAULT_STROKE
/// Stroke options, in world coordinates
const STROKE_OPTIONS: StrokeOptions = StrokeOptions::DEFAULT
.with_line_width(100000.0)
.with_line_width(10000.0)
.with_line_cap(lyon::path::LineCap::Square)
.with_tolerance(100.0);
const DEFAULT_BUFFER_LEN: u64 = 1024 * 1024;
Expand Down Expand Up @@ -271,7 +273,6 @@ impl TessCtx {
// })],
targets: &[Some(render_state.target_format.into())],
}),
// primitive: wgpu::PrimitiveState::default(),
primitive: wgpu::PrimitiveState {
// topology: wgpu::PrimitiveTopology::LineList,
topology: wgpu::PrimitiveTopology::TriangleList,
Expand Down Expand Up @@ -368,19 +369,19 @@ impl TessCtx {

if self.render_fill() {
with_aligned_buf(&mut self.fill_geometry.vertices, |buf| {
queue.write_buffer(&self.fill_vbo, 0, buf)
queue.write_buffer(&self.fill_vbo, 0, buf);
});
with_aligned_buf(&mut self.fill_geometry.indices, |buf| {
queue.write_buffer(&self.fill_ibo, 0, buf)
queue.write_buffer(&self.fill_ibo, 0, buf);
});
}

if self.render_stroke() {
with_aligned_buf(&mut self.stroke_geometry.vertices, |buf| {
queue.write_buffer(&self.stroke_vbo, 0, buf)
queue.write_buffer(&self.stroke_vbo, 0, buf);
});
with_aligned_buf(&mut self.stroke_geometry.indices, |buf| {
queue.write_buffer(&self.stroke_ibo, 0, buf)
queue.write_buffer(&self.stroke_ibo, 0, buf);
});
}
}
Expand All @@ -401,14 +402,22 @@ impl TessCtx {
render_pass.insert_debug_marker("debug fill");
render_pass.set_vertex_buffer(0, self.fill_vbo.slice(..));
render_pass.set_index_buffer(self.fill_ibo.slice(..), wgpu::IndexFormat::Uint16);
render_pass.draw_indexed(0..self.fill_geometry.indices.len() as u32, 0, 0..1);
render_pass.draw_indexed(
0..self.fill_geometry.indices.len().try_into().unwrap(),
0,
0..1,
);
}

if self.render_stroke() {
render_pass.insert_debug_marker("debug stroke");
render_pass.set_vertex_buffer(0, self.stroke_vbo.slice(..));
render_pass.set_index_buffer(self.stroke_ibo.slice(..), wgpu::IndexFormat::Uint16);
render_pass.draw_indexed(0..self.stroke_geometry.indices.len() as u32, 0, 0..1);
render_pass.draw_indexed(
0..self.stroke_geometry.indices.len().try_into().unwrap(),
0,
0..1,
);
}
}
}
Expand Down Expand Up @@ -534,7 +543,7 @@ where
f(bytemuck::cast_slice(buf));

// Remove the temporary elements so we can continue appending to the buffer later
buf.truncate(buf.len() - (to_add as usize));
buf.truncate(buf.len() - usize::try_from(to_add).unwrap());
}

mod alt_to_lyon {
Expand Down
2 changes: 2 additions & 0 deletions ecadg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::missing_panics_doc)]
#![allow(clippy::too_many_lines)]
#![allow(clippy::cast_precision_loss)]

mod app;
mod backend;
Expand Down

0 comments on commit 5cb7571

Please sign in to comment.