Skip to content

Commit

Permalink
Merge branch 'clippy' of github.com:MarijnS95/ispc-rs into MarijnS95-…
Browse files Browse the repository at this point in the history
…clippy
  • Loading branch information
Twinklebear committed Oct 25, 2022
2 parents ec149c6 + 25f8196 commit 26d8d2e
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- run: curl -L https://github.com/ispc/ispc/releases/download/v${{ env.ISPC_VERSION }}/ispc-v${{ env.ISPC_VERSION }}-linux.tar.gz | tar xzv ispc-v${{ env.ISPC_VERSION }}-linux/bin/ispc
- run: realpath "ispc-v${{ env.ISPC_VERSION }}-linux/bin/" >> $GITHUB_PATH
- run: cargo build --all --all-targets --features ispc
- run: cargo clippy --all --all-targets --features ispc -- -D warnings
- run: cargo test --all
- run: cargo doc --all --no-deps --document-private-items --all-features
env:
Expand All @@ -33,6 +34,7 @@ jobs:
toolchain: stable
- run: brew install ispc
- run: cargo build --all --all-targets --features ispc
- run: cargo clippy --all --all-targets --features ispc -- -D warnings
- run: cargo test --all
build_windows:
runs-on: windows-latest
Expand All @@ -46,4 +48,5 @@ jobs:
unzip ispc-v${{ env.ISPC_VERSION }}-windows.zip ispc-v${{ env.ISPC_VERSION }}-windows/bin/ispc.exe
Resolve-Path "ispc-v${{ env.ISPC_VERSION }}-windows/bin" | Add-Content -Path $env:GITHUB_PATH
- run: cargo build --all --all-targets --features ispc
- run: cargo clippy --all --all-targets --features ispc -- -D warnings
- run: cargo test --all
2 changes: 1 addition & 1 deletion compile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub use crate::opt::{
/// ```
pub fn compile_library(lib: &str, files: &[&str]) {
let mut cfg = Config::new();
for f in &files[..] {
for f in files {
cfg.file(*f);
}
cfg.compile(lib)
Expand Down
2 changes: 1 addition & 1 deletion compile/src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl ToString for OptimizationOpt {

/// Target instruction sets and vector widths available to specialize for. The
/// default if none is set will be the host CPU's ISA and vector width.
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum TargetISA {
Host,
SSE2i32x4,
Expand Down
4 changes: 2 additions & 2 deletions examples/ddvol/src/fb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub struct Framebuffer {
impl Framebuffer {
pub fn new(width: usize, height: usize) -> Framebuffer {
Framebuffer {
width: width,
height: height,
width,
height,
data: vec![0.0; width * height * 4],
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/ddvol/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn empty_handle() -> ISPCHandle {
ptr::null::<*mut ::std::os::raw::c_void>() as ISPCHandle
}

const USAGE: &'static str = "
const USAGE: &str = "
Usage:
ddvol <scene> [options]
ddvol (-h | --help)
Expand Down Expand Up @@ -84,7 +84,7 @@ fn main() {
);
}
let out_file = match args.flag_o {
Some(s) => s.clone(),
Some(s) => s,
None => String::from("ddvol.png"),
};
let srgb_img = framebuffer.srgb8();
Expand Down
12 changes: 6 additions & 6 deletions examples/ddvol/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ impl Scene {
.expect("image height must be an int") as usize;
let mut volume = Scene::load_volume(
data.get("volume").expect("A volume must be specified"),
&base_path,
base_path,
);
let tfn = Scene::load_transfer_function(
data.get("transfer_function")
.expect("A transfer function must be specified"),
&base_path,
base_path,
);
volume.set_transfer_function(tfn);

Expand All @@ -103,8 +103,8 @@ impl Scene {
Scene {
width: img_width,
height: img_height,
camera: camera,
volume: volume,
camera,
volume,
params: render_params,
}
}
Expand Down Expand Up @@ -273,8 +273,8 @@ impl Scene {
.as_i64()
.expect("n_samples must be an int") as i32;
RenderParams {
background: background,
n_samples: n_samples,
background,
n_samples,
}
}
fn load_vec3i(e: &Value) -> Option<Vec3i> {
Expand Down
10 changes: 5 additions & 5 deletions examples/ddvol/src/vec3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ pub type Vec3i = crate::ddvol::Vec3i;

impl Vec3f {
pub fn broadcast(x: f32) -> Vec3f {
Vec3f { x: x, y: x, z: x }
Vec3f { x, y: x, z: x }
}
pub fn new(x: f32, y: f32, z: f32) -> Vec3f {
Vec3f { x: x, y: y, z: z }
Vec3f { x, y, z }
}
pub fn dot(&self, b: &Vec3f) -> f32 {
self.x * b.x + self.y * b.y + self.z * b.z
}
pub fn length(&self) -> f32 {
f32::sqrt(self.dot(&self))
f32::sqrt(self.dot(self))
}
pub fn normalized(&self) -> Vec3f {
let inv_len = 1.0 / self.length();
Expand Down Expand Up @@ -131,10 +131,10 @@ impl Div<f32> for Vec3f {

impl Vec3i {
pub fn broadcast(x: i32) -> Vec3i {
Vec3i { x: x, y: x, z: x }
Vec3i { x, y: x, z: x }
}
pub fn new(x: i32, y: i32, z: i32) -> Vec3i {
Vec3i { x: x, y: y, z: z }
Vec3i { x, y, z }
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/ddvol/src/vol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Volume {
}
Volume {
ispc_handle: vol,
tfn: tfn,
tfn,
}
}
/// Set the transfer function used by the volume, overriding the default cool/warm.
Expand Down
8 changes: 4 additions & 4 deletions examples/rt/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ impl Camera {
let screen_dv = dy * dim_y;
let dir_top_left = dz - 0.5 * screen_du - 0.5 * screen_dv;
Camera {
pos: pos,
pos,
dir: dir.normalized(),
up: up.normalized(),
dir_top_left: dir_top_left,
screen_du: screen_du,
screen_dv: screen_dv,
dir_top_left,
screen_du,
screen_dv,
width: width as i32,
height: height as i32,
}
Expand Down
6 changes: 3 additions & 3 deletions examples/rt/src/geom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ impl Sphere {
);
}
Sphere {
center: center,
radius: radius,
center,
radius,
material: mat,
ispc_geom: geom,
}
Expand Down Expand Up @@ -82,7 +82,7 @@ impl Plane {
);
}
Plane {
center: center,
center,
normal: n,
material: mat,
ispc_geom: geom,
Expand Down
4 changes: 2 additions & 2 deletions examples/rt/src/lights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl PointLight {
);
}
PointLight {
position: position,
emission: emission,
position,
emission,
ispc_equiv: light,
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/rt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod vec3f;

ispc_module!(rt);

const USAGE: &'static str = "
const USAGE: &str = "
Usage:
rt <scene> [options]
rt (-h | --help)
Expand Down Expand Up @@ -83,7 +83,7 @@ fn main() {
);
}
let out_file = match args.flag_o {
Some(s) => s.clone(),
Some(s) => s,
None => String::from("rt.png"),
};
match image::save_buffer(
Expand Down
2 changes: 1 addition & 1 deletion examples/rt/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Lambertian {
rt::make_lambertian(&mut mat as *mut *const Material, &albedo as *const Vec3f);
}
Lambertian {
albedo: albedo,
albedo,
ispc_equiv: mat,
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/rt/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ impl Scene {
Scene {
width: img_width,
height: img_height,
n_samples: n_samples,
camera: camera,
n_samples,
camera,
geometry: geom,
light: light,
light,
}
}
fn load_camera(e: &Value, width: usize, height: usize) -> Camera {
Expand Down
6 changes: 3 additions & 3 deletions examples/rt/src/vec3f.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ pub type Vec3f = crate::rt::Vec3f;

impl Vec3f {
pub fn broadcast(x: f32) -> Vec3f {
Vec3f { x: x, y: x, z: x }
Vec3f { x, y: x, z: x }
}
pub fn new(x: f32, y: f32, z: f32) -> Vec3f {
Vec3f { x: x, y: y, z: z }
Vec3f { x, y, z }
}
pub fn dot(&self, b: &Vec3f) -> f32 {
self.x * b.x + self.y * b.y + self.z * b.z
}
pub fn length(&self) -> f32 {
f32::sqrt(self.dot(&self))
f32::sqrt(self.dot(self))
}
pub fn normalized(&self) -> Vec3f {
let inv_len = 1.0 / self.length();
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl Context {
let tasks = self.tasks.read().unwrap();
for group in tasks.iter() {
if group.has_tasks() {
return Some(Arc::clone(&group));
return Some(Arc::clone(group));
}
}
None
Expand Down

0 comments on commit 26d8d2e

Please sign in to comment.