From 49de0341a0dd7ffd4a65aa5f75e6fa82390885b6 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Wed, 11 Oct 2023 20:58:21 +0200 Subject: [PATCH] CI: Cross-lint for Mac, iOS and Windows (#796) * CI: Cross-lint for Mac, iOS and Windows We have some conditional code specific to Mac and iOS which is currently untested in the CI, allowing non-compiling code in PRs like #795 to go unnoticed. * Fix new clippy lints --- .github/workflows/ci.yml | 19 ++++++++++++++++--- generator/src/lib.rs | 6 +++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd2915449..81d83ae75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,17 +61,30 @@ jobs: clippy: name: Clippy runs-on: ubuntu-latest + strategy: + matrix: + target: + - x86_64-pc-windows-msvc + - x86_64-unknown-linux-gnu + - x86_64-apple-darwin + - aarch64-apple-ios steps: - uses: actions/checkout@v1 + - name: Add Rust target ${{ matrix.target }} + run: rustup target add ${{ matrix.target }} - name: Clippy lint without features # Only test the core ash, ash-rewrite and ash-window crate, where features reside. # The examples crate would otherwise enable all default features again, # making this test moot. - run: cargo clippy -p ash -p ash-rewrite -p ash-window --no-default-features -- -D warnings + run: cargo clippy --target ${{ matrix.target }} -p ash -p ash-rewrite -p ash-window --no-default-features -- -D warnings - name: Clippy lint with all features - run: cargo clippy --workspace --all-targets --all-features -- -D warnings + # Examples don't compile for iOS currently due to lacking run_return() + if: ${{ matrix.target != 'aarch64-apple-ios' }} + run: cargo clippy --target ${{ matrix.target }} --workspace --all-targets --all-features -- -D warnings - name: Clippy lint with default features - run: cargo clippy --workspace --all-targets -- -D warnings + # Examples don't compile for iOS currently due to lacking run_return() + if: ${{ matrix.target != 'aarch64-apple-ios' }} + run: cargo clippy --target ${{ matrix.target }} --workspace --all-targets -- -D warnings docs: name: Build-test docs diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 2b897afac..7db199eb9 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -305,7 +305,7 @@ pub trait ConstantExt { fn variant_ident(&self, enum_name: &str) -> Ident; fn notation(&self) -> Option<&str>; fn formatted_notation(&self) -> Option> { - static DOC_LINK: Lazy = Lazy::new(|| Regex::new(r#"<<([\w-]+)>>"#).unwrap()); + static DOC_LINK: Lazy = Lazy::new(|| Regex::new(r"<<([\w-]+)>>").unwrap()); self.notation().map(|n| { DOC_LINK.replace( n, @@ -2968,13 +2968,13 @@ pub fn write_source_code>(vk_headers_dir: &Path, src_dir: P) { let mut has_lifetimes = definitions .iter() .filter_map(get_variant!(vkxml::DefinitionsElement::Struct)) - .filter_map(|s| { + .filter(|&s| { s.elements .iter() .filter_map(get_variant!(vkxml::StructElement::Member)) .any(|x| x.reference.is_some()) - .then(|| name_to_tokens(&s.name)) }) + .map(|s| name_to_tokens(&s.name)) .collect::>(); for def in &definitions { match def {