diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 157f791a..9e379cf1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,11 +28,27 @@ jobs: with: toolchain: stable override: true + profile: minimal components: rustfmt - uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check + clippy: + name: Cargo clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + profile: minimal + components: clippy + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all --all-targets -- -Dwarnings test: name: Cargo check and test strategy: @@ -47,6 +63,7 @@ jobs: with: toolchain: ${{ matrix.rust }} override: true + profile: minimal - uses: actions-rs/cargo@v1 with: command: check diff --git a/autogen/Cargo.toml b/autogen/Cargo.toml index 10a0174d..43c85fd7 100644 --- a/autogen/Cargo.toml +++ b/autogen/Cargo.toml @@ -6,6 +6,7 @@ authors = [ "Lei Zhang ", ] edition = "2018" +rust-version = "1.58" publish = false diff --git a/autogen/src/dr.rs b/autogen/src/dr.rs index 2c78338c..e247c8ca 100644 --- a/autogen/src/dr.rs +++ b/autogen/src/dr.rs @@ -24,7 +24,7 @@ pub fn operand_has_additional_params( kinds .iter() .find(|kind| kind.kind == operand.kind) - .map_or(false, |kind| has_additional_params(kind)) + .map_or(false, has_additional_params) } fn get_param_or_arg_list( diff --git a/autogen/src/header.rs b/autogen/src/header.rs index eb78e537..2764e81e 100644 --- a/autogen/src/header.rs +++ b/autogen/src/header.rs @@ -4,6 +4,7 @@ use crate::utils::*; use heck::{ShoutySnakeCase, SnakeCase}; use proc_macro2::TokenStream; use quote::quote; +use std::cmp::Ordering; use std::collections::BTreeMap; static GLSL_STD_450_SPEC_LINK: &str = "\ @@ -17,13 +18,7 @@ https://www.khronos.org/registry/spir-v/specs/unified1/OpenCL.ExtendedInstructio fn get_spec_link(kind: &str) -> String { let symbol = kind.to_snake_case(); format!( - "[{text}]({link})", - text = kind, - link = format!( - "https://www.khronos.org/registry/spir-v/\ - specs/unified1/SPIRV.html#_a_id_{}_a_{}", - symbol, symbol - ) + "[{kind}](https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#_a_id_{symbol}_a_{symbol})", ) } @@ -60,12 +55,10 @@ fn generate_enum( let mut number_runs = vec![(variants[0].0, variants[0].0)]; for &(number, _) in variants.iter().skip(1) { let last_run = number_runs.last_mut().unwrap(); - if number == last_run.1 + 1 { - last_run.1 = number; - } else if number > last_run.1 + 1 { - number_runs.push((number, number)); - } else { - unreachable!("Variants not sorted by discriminant"); + match number.cmp(&(last_run.1 + 1)) { + Ordering::Equal => last_run.1 = number, + Ordering::Greater => number_runs.push((number, number)), + Ordering::Less => unreachable!("Variants not sorted by discriminant"), } } diff --git a/rspirv/binary/disassemble.rs b/rspirv/binary/disassemble.rs index 63ade951..5aeb7bd6 100644 --- a/rspirv/binary/disassemble.rs +++ b/rspirv/binary/disassemble.rs @@ -55,11 +55,11 @@ impl Disassemble for dr::Instruction { fn disassemble(&self) -> String { let space = if !self.operands.is_empty() { " " } else { "" }; format!( - "{rid}{opcode}{rtype}{space}{operands}", + "{rid}Op{opcode}{rtype}{space}{operands}", rid = self .result_id .map_or(String::new(), |w| format!("%{} = ", w)), - opcode = format!("Op{}", self.class.opname), + opcode = self.class.opname, // extra space both before and after the reseult type rtype = self .result_type @@ -192,11 +192,11 @@ fn disas_ext_inst( operands.push(operand.disassemble()) } format!( - "{rid}{opcode}{rtype} {operands}", + "{rid}Op{opcode}{rtype} {operands}", rid = inst .result_id .map_or(String::new(), |w| format!("%{} = ", w)), - opcode = format!("Op{}", inst.class.opname), + opcode = inst.class.opname, rtype = inst .result_type .map_or(String::new(), |w| format!(" %{} ", w)),