Skip to content

Reduce required sym features - #144

Merged
danlehmann merged 9 commits into
danlehmann:mainfrom
seritools:reduce-sym-features
Aug 27, 2026
Merged

Reduce required sym features#144
danlehmann merged 9 commits into
danlehmann:mainfrom
seritools:reduce-sym-features

Conversation

@seritools

Copy link
Copy Markdown
Contributor

While checking if something needs to be changed for #143 I noticed that the big full feature of sym mostly isn't necessary.

In a local test this reduced the compile time from ~2s to ~1.3s. Feel free to drop if the extra code is not worth it.

`DeriveInput` covers everything the macro needs (attrs, vis, ident and the variants), but unlike `ItemEnum` it doesn't require `syn`s full feature.

Applying #[bitenum] to a struct or union now reports a dedicated error instead of syn's generic "expected `enum`", spanned at the struct/union keyword.
The elements are re-tokenized and fed back into parse_argument_tokens anyway, so all this needed was a split at the top-level commas. syn::ExprArray requires the "full" feature.

A group with the wrong delimiter, e.g. #[bits((0..=1), rw)], now reports an error rather than panicking in the unwrap that used to be here.
@danlehmann
danlehmann force-pushed the reduce-sym-features branch from 03b1b0a to 76a286e Compare August 26, 2026 20:30
- Reject genuinely empty elements in bit-range arrays (e.g. [0..=1,, 4..=5]
  or [,0..=1]) with a dedicated error instead of silently ignoring them;
  a trailing comma remains allowed.
- Give delimiter-specific error messages when bit-ranges are wrapped in the
  wrong delimiters (parentheses, braces) instead of a generic message.
Covers the error messages introduced when #[bitenum] started parsing its
input as a DeriveInput and bit-range arrays stopped being parsed via
ExprArray:

- #[bitenum] on a struct or a union reports a dedicated 'can only be
  applied to an enum' error, and the original item is still emitted (both
  tests reference the item, so a regression that dropped it would add a
  missing-type error and fail the test).
- Non-bracket delimiters (e.g. (0..=1)) or empty elements (e.g.
  [0..=1,, 4..=5]) in bit-range arrays are rejected with a clear message.
bitbybit now depends on syn 3, but the committed lockfile for the
excluded-from-workspace qemu-tests crate still pinned syn 2.0.104, so the
build-no-std CI job would silently rewrite the lockfile on every build.
Regenerate it: bitbybit resolves to syn 3.0.4 while the remaining crates
(defmt-macros, cortex-m-rt, ...) stay on syn 2.0.119 as a separate version.
Describe the user-visible changes of PR danlehmann#144: the syn 3 upgrade (with the
dropped 'full' feature) which has no API impact, the dedicated #[bitenum]
error for non-enums, and the clearer bit-range array errors that replace a
proc-macro panic.
@danlehmann
danlehmann merged commit 93cef27 into danlehmann:main Aug 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants