Skip to content

Commit

Permalink
Check Clippy in CI; forbid warnings (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter authored Nov 9, 2024
1 parent 638555c commit 9408fd0
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings

jobs:
check:
Expand All @@ -26,3 +27,5 @@ jobs:
run: rustup target add ${{ matrix.target }}
- name: Check
run: cargo check --target=${{ matrix.target }} --all-targets --verbose
- name: Clippy
run: cargo clippy --target=${{ matrix.target }} --all-targets --verbose
3 changes: 3 additions & 0 deletions .github/workflows/check-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings

jobs:
check:
Expand All @@ -26,3 +27,5 @@ jobs:
# cargo check doesn't find MIR diagnostics, so we use cargo build instead
# (https://github.com/rust-lang/rust/issues/49292)
run: cargo build --target=${{ matrix.target }} -pfidget --no-default-features --features="rhai,render,mesh"
- name: Clippy
run: cargo clippy --target=${{ matrix.target }} -pfidget --no-default-features --features="rhai,render,mesh"
3 changes: 3 additions & 0 deletions .github/workflows/check-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings

jobs:
check:
Expand All @@ -25,3 +26,5 @@ jobs:
run: rustup target add ${{ matrix.target }}
- name: Check
run: cargo check --target=${{ matrix.target }} --all-targets --verbose
- name: Clippy
run: cargo clippy --target=${{ matrix.target }} --all-targets --verbose
5 changes: 4 additions & 1 deletion fidget/src/core/eval/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ pub trait TracingEvaluator: Default {
&mut self,
tape: &Self::Tape,
vars: &[Self::Data],
) -> Result<(&[Self::Data], Option<&Self::Trace>), Error>;
) -> Result<TracingResult<Self::Data, Self::Trace>, Error>;

/// Build a new empty evaluator
fn new() -> Self {
Self::default()
}
}

/// Tuple of tracing evaluation result
type TracingResult<'a, Data, Trace> = (&'a [Data], Option<&'a Trace>);
8 changes: 4 additions & 4 deletions fidget/src/jit/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use windows::Win32::System::Memory::{
};

pub struct Mmap {
ptr: *mut libc::c_void,
ptr: *mut std::ffi::c_void,
len: usize,
}

Expand All @@ -21,7 +21,7 @@ impl Default for Mmap {
impl Mmap {
pub fn empty() -> Self {
Self {
ptr: std::ptr::null_mut::<libc::c_void>(),
ptr: std::ptr::null_mut::<std::ffi::c_void>(),
len: 0,
}
}
Expand Down Expand Up @@ -101,7 +101,7 @@ impl Mmap {
}

/// Returns the inner pointer
pub fn as_ptr(&self) -> *mut libc::c_void {
pub fn as_ptr(&self) -> *const std::ffi::c_void {
self.ptr
}
}
Expand Down Expand Up @@ -253,7 +253,7 @@ mod macos {

#[link(name = "pthread")]
extern "C" {
pub fn pthread_jit_write_protect_np(enabled: libc::c_int);
pub fn pthread_jit_write_protect_np(enabled: std::ffi::c_int);
}

#[link(name = "c")]
Expand Down
50 changes: 33 additions & 17 deletions fidget/src/jit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,12 @@ impl JitFunction {
vars: self.0.data().vars.clone(),
choice_count: self.0.choice_count(),
output_count: self.0.output_count(),
fn_trace: unsafe { std::mem::transmute(ptr) },
fn_trace: unsafe {
std::mem::transmute::<
*const std::ffi::c_void,
JitTracingFnPointer<A::Data>,
>(ptr)
},
}
}
fn bulk_tape<A: Assembler>(&self, storage: Mmap) -> JitBulkFn<A::Data> {
Expand All @@ -860,7 +865,12 @@ impl JitFunction {
mmap: f,
output_count: self.0.output_count(),
vars: self.0.data().vars.clone(),
fn_bulk: unsafe { std::mem::transmute(ptr) },
fn_bulk: unsafe {
std::mem::transmute::<
*const std::ffi::c_void,
JitBulkFnPointer<A::Data>,
>(ptr)
},
}
}
}
Expand Down Expand Up @@ -989,21 +999,24 @@ impl<T> Default for JitTracingEval<T> {
}
}

/// Typedef for a tracing function pointer
pub type JitTracingFnPointer<T> = jit_fn!(
unsafe fn(
*const T, // vars
*mut u8, // choices
*mut u8, // simplify (single boolean)
*mut T, // output (array)
)
);

/// Handle to an owned function pointer for tracing evaluation
pub struct JitTracingFn<T> {
#[allow(unused)]
mmap: Mmap,
choice_count: usize,
output_count: usize,
vars: Arc<VarMap>,
fn_trace: jit_fn!(
unsafe fn(
*const T, // vars
*mut u8, // choices
*mut u8, // simplify (single boolean)
*mut T, // output (array)
)
),
fn_trace: JitTracingFnPointer<T>,
}

impl<T> Tape for JitTracingFn<T> {
Expand Down Expand Up @@ -1098,19 +1111,22 @@ impl TracingEvaluator for JitPointEval {

////////////////////////////////////////////////////////////////////////////////

/// Typedef for a bulk function pointer
pub type JitBulkFnPointer<T> = jit_fn!(
unsafe fn(
*const *const T, // vars
*const *mut T, // out
u64, // size
)
);

/// Handle to an owned function pointer for bulk evaluation
pub struct JitBulkFn<T> {
#[allow(unused)]
mmap: Mmap,
vars: Arc<VarMap>,
output_count: usize,
fn_bulk: jit_fn!(
unsafe fn(
*const *const T, // vars
*const *mut T, // out
u64, // size
)
),
fn_bulk: JitBulkFnPointer<T>,
}

impl<T> Tape for JitBulkFn<T> {
Expand Down
1 change: 1 addition & 0 deletions workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ version = "0.1.0"
description = "workspace-hack package, managed by hakari"
# You can choose to publish this crate: see https://docs.rs/cargo-hakari/latest/cargo_hakari/publishing.
publish = false
edition = "2021"

# The parts of the file between the BEGIN HAKARI SECTION and END HAKARI SECTION comments
# are managed by hakari.
Expand Down

0 comments on commit 9408fd0

Please sign in to comment.