Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Run clippy -Dwarnings and use minimal toolchain profile #223

Merged
merged 4 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -47,6 +63,7 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
override: true
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: check
Expand Down
1 change: 1 addition & 0 deletions autogen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ authors = [
"Lei Zhang <antiagainst@gmail.com>",
]
edition = "2018"
rust-version = "1.58"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 years later, I don't understand why I added this: autogen is the only crate that is not published and shouldn't care about the version at all, since Rust developers contributing to this repository and specifically using the generator to regenerate its contents can easily use the latest stable at all times.


publish = false

Expand Down
2 changes: 1 addition & 1 deletion autogen/src/dr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 6 additions & 13 deletions autogen/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "\
Expand All @@ -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})",
)
}

Expand Down Expand Up @@ -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"),
}
}

Expand Down
8 changes: 4 additions & 4 deletions rspirv/binary/disassemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)),
Expand Down