From cc5837b79e0a60187a03c615d1dcdde2b54f4777 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sat, 18 Nov 2023 08:05:25 +0000 Subject: [PATCH] update ci --- .github/dependabot.yml | 6 ++++ .github/workflows/ci.yml | 73 +++++++++++----------------------------- core/parse_helpers.rs | 7 ++-- core/small_string.rs | 1 + macros/types/field.rs | 29 +++++++++------- 5 files changed, 48 insertions(+), 68 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..71607d0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d577df7..366cca2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,78 +11,45 @@ env: jobs: build_and_test: - name: Deluxe + name: Build & Test + strategy: + matrix: + features: ["--all-features", "--no-default-features"] runs-on: ubuntu-latest timeout-minutes: 45 steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - run: cargo build -r --all-features --workspace - - run: cargo test -r --all-features --workspace - - build_and_test_no_default: - name: Deluxe No Default Features - runs-on: ubuntu-latest - timeout-minutes: 45 - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - run: cargo build -r --no-default-features --workspace - - run: cargo test -r --no-default-features --workspace + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo build -r ${{ matrix.features }} --workspace + - run: cargo test -r ${{ matrix.features }} --workspace rustfmt: - name: Deluxe Rustfmt + name: Rustfmt runs-on: ubuntu-latest timeout-minutes: 45 steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - override: true components: rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - run: cargo fmt --all --check clippy: - name: Deluxe Clippy + name: Clippy runs-on: ubuntu-latest timeout-minutes: 45 steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - override: true components: clippy - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --workspace + - run: cargo clippy --workspace --all-targets docs: - name: Deluxe Docs + name: Docs runs-on: ubuntu-latest timeout-minutes: 45 steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rust-docs - - uses: actions-rs/cargo@v1 - with: - command: doc - args: --workspace + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo doc --workspace --no-deps diff --git a/core/parse_helpers.rs b/core/parse_helpers.rs index 18748bd..d37b5db 100644 --- a/core/parse_helpers.rs +++ b/core/parse_helpers.rs @@ -939,8 +939,10 @@ where P: crate::ParseAttributes<'t, T>, T: crate::HasAttributes, { - T::attrs(input).iter().filter_map(|a| { - P::path_matches(a.path()).then(|| { + T::attrs(input) + .iter() + .filter(|&a| P::path_matches(a.path())) + .map(|a| { let value = match &a.meta { syn::Meta::Path(_) => Default::default(), syn::Meta::List(list) => proc_macro2::TokenTree::Group(proc_macro2::Group::new( @@ -956,7 +958,6 @@ where }; (value, key_to_string(a.path()), a.path().span()) }) - }) } /// Returns an iterator of [`TokenStream`](proc_macro2::TokenStream)s and the corresponding path diff --git a/core/small_string.rs b/core/small_string.rs index 1ecd2b8..7e7bfb9 100644 --- a/core/small_string.rs +++ b/core/small_string.rs @@ -103,6 +103,7 @@ impl<'a> Ord for SmallString<'a> { } } +#[allow(clippy::non_canonical_partial_ord_impl)] impl<'a> PartialOrd for SmallString<'a> { #[inline] fn partial_cmp(&self, other: &Self) -> Option { diff --git a/macros/types/field.rs b/macros/types/field.rs index a02e729..eaef790 100644 --- a/macros/types/field.rs +++ b/macros/types/field.rs @@ -507,9 +507,13 @@ impl<'f> Field<'f> { .enumerate() .map(|(i, _)| quote::format_ident!("field{i}", span = Span::mixed_site())) .collect::>(); - let container_def = fields.iter().enumerate().filter_map(|(i, f)| { - (f.is_container() && *mode != TokenMode::ParseMetaItem).then(|| { - let name = names[i].clone(); + let container_def = fields + .iter() + .zip(&names) + .filter_map(|(f, name)| { + (f.is_container() && *mode != TokenMode::ParseMetaItem).then_some(name) + }) + .map(|name| { let func = match mode { TokenMode::ParseAttributes => quote! { container_from }, TokenMode::ExtractAttributes => quote! { container_from_mut }, @@ -518,8 +522,7 @@ impl<'f> Field<'f> { quote_mixed! { #name = #priv_::FieldStatus::Some(#crate_::ContainerFrom::#func(obj)); } - }) - }); + }); let field_errors = { let mut cur_index = 0usize; let mut extra_counts = quote! {}; @@ -685,14 +688,16 @@ impl<'f> Field<'f> { #(#transforms)* } }); - let field_unwraps = fields.iter().enumerate().filter_map(|(i, _)| { - (!matches!(target, ParseTarget::Var(_))).then(|| { - let name = &names[i]; - quote_mixed! { - let #name = #name.unwrap_or_else(|| #priv_::unreachable!()); - } + let field_unwraps = (!matches!(target, ParseTarget::Var(_))) + .then(|| { + names.iter().take(fields.len()).map(|name| { + quote_mixed! { + let #name = #name.unwrap_or_else(|| #priv_::unreachable!()); + } + }) }) - }); + .into_iter() + .flatten(); let option_inits = fields.iter().enumerate().map(|(i, f)| { let name = &names[i];