From 76f0726effdddbb58daf32f0a685f1ec98527d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dj8yf0=CE=BCl?= <26653921+dj8yfo@users.noreply.github.com> Date: Mon, 26 Feb 2024 20:16:40 +0200 Subject: [PATCH] ci: fix `test_exhaustive_checks` step + downgrade package for MSRV test (#280) * ci: fix `test_exhaustive_checks` step * ci: downgrade package for MSRV build --- .github/workflows/rust.yml | 6 +++++- borsh-derive/src/internals/generics.rs | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 670d42ac6..cacfb8dac 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -36,6 +36,10 @@ jobs: run: rustup default ${{ matrix.rust_version }} - name: print rustc version run: rustc --version + - name: downgrade `toml_edit`, time`, `toml_datetime` crate to support older Rust toolchain + if: matrix.rust_version == '1.67.0' + run: | + cargo update -p toml_edit --precise 0.21.0 - name: Run tests run: ./.github/test.sh @@ -51,7 +55,7 @@ jobs: # consult https://github.com/serde-rs/serde/blob/master/serde_derive/src/bound.rs#L100 , # the implementation of `FindTyParams` may have been updated already - name: Run exhaustive check tests - run: cargo check --workspace --features force_exhaustive_checks + run: RUSTFLAGS="-A unused_imports -D warnings" cargo check --workspace --features force_exhaustive_checks clippy: runs-on: ubuntu-20.04 diff --git a/borsh-derive/src/internals/generics.rs b/borsh-derive/src/internals/generics.rs index f38b52bfe..61a4fa579 100644 --- a/borsh-derive/src/internals/generics.rs +++ b/borsh-derive/src/internals/generics.rs @@ -209,6 +209,10 @@ impl FindTyParams { PathArguments::None => {} PathArguments::AngleBracketed(arguments) => { for arg in &arguments.args { + #[cfg_attr( + feature = "force_exhaustive_checks", + deny(non_exhaustive_omitted_patterns) + )] match arg { GenericArgument::Type(arg) => self.visit_type(arg), GenericArgument::AssocType(arg) => self.visit_type(&arg.ty), @@ -216,10 +220,6 @@ impl FindTyParams { | GenericArgument::Const(_) | GenericArgument::AssocConst(_) | GenericArgument::Constraint(_) => {} - #[cfg_attr( - feature = "force_exhaustive_checks", - deny(non_exhaustive_omitted_patterns) - )] _ => {} } } @@ -253,13 +253,13 @@ impl FindTyParams { } fn visit_type_param_bound(&mut self, bound: &TypeParamBound) { + #[cfg_attr( + feature = "force_exhaustive_checks", + deny(non_exhaustive_omitted_patterns) + )] match bound { TypeParamBound::Trait(bound) => self.visit_path(&bound.path), TypeParamBound::Lifetime(_) | TypeParamBound::Verbatim(_) => {} - #[cfg_attr( - feature = "force_exhaustive_checks", - deny(non_exhaustive_omitted_patterns) - )] _ => {} } } @@ -272,6 +272,10 @@ impl FindTyParams { fn visit_macro(&mut self, _mac: &Macro) {} fn visit_type(&mut self, ty: &Type) { + #[cfg_attr( + feature = "force_exhaustive_checks", + deny(non_exhaustive_omitted_patterns) + )] match ty { Type::Array(ty) => self.visit_type(&ty.elem), Type::BareFn(ty) => { @@ -310,10 +314,6 @@ impl FindTyParams { Type::Infer(_) | Type::Never(_) | Type::Verbatim(_) => {} - #[cfg_attr( - feature = "force_exhaustive_checks", - deny(non_exhaustive_omitted_patterns) - )] _ => {} } }