Skip to content
Draft
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
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: cargo
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

can safely bump dependencies using dependabot since any change to the MSRV introduced by dependency updates will be caught in CI

directory: "/"
schedule:
interval: daily
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
84 changes: 31 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,78 +11,56 @@ 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@nightly
- 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@nightly
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@master
with:
profile: minimal
toolchain: stable
override: true
toolchain: nightly-2023-11-18
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

msrv:
runs-on: ubuntu-latest
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@cargo-no-dev-deps
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this allows checking the MSRV for the non-dev deps only (since this is the MSRV that downstream users are impacted by). This means you can freely use newer versions + syntax for dev-deps

- uses: dtolnay/rust-toolchain@1.67.1
- run: cargo no-dev-deps check
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ readme = "README.md"
keywords = ["macros", "derive", "attributes"]
include = ["/src", "/tests", "/README.md", "/COPYING"]
resolver = "2"
rust-version = "1.67.1"

[features]
default = ["full", "proc-macro"]
Expand Down
7 changes: 4 additions & 3 deletions core/parse_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions core/small_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::cmp::Ordering> {
Expand Down
29 changes: 17 additions & 12 deletions macros/types/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,13 @@ impl<'f> Field<'f> {
.enumerate()
.map(|(i, _)| quote::format_ident!("field{i}", span = Span::mixed_site()))
.collect::<Vec<_>>();
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 },
Expand All @@ -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! {};
Expand Down Expand Up @@ -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];
Expand Down