Skip to content

refactor(macros): bump syn to v3 - #679

Open
AudaciousAxiom wants to merge 2 commits into
rust-embedded:masterfrom
AudaciousAxiom:refactor/syn-v3
Open

refactor(macros): bump syn to v3#679
AudaciousAxiom wants to merge 2 commits into
rust-embedded:masterfrom
AudaciousAxiom:refactor/syn-v3

Conversation

@AudaciousAxiom

Copy link
Copy Markdown

Following the release of a new major version of syn, this bumps the version used by cortex-m-macros and cortex-m-rt-macros, with the goal of eventually removing the duplicated dependency in binaries (and therefore reducing compile times).

syn v3 advertises an MSRV of 1.71, so this shouldn't affect the MSRV of these crates given the recent bump to 1.85.

I've gone through the changelog and did the necessary refactor; I didn't find any other relevant breaking changes (but there are quite a few of them so I could have missed some). I've run cargo test but didn't do any other kind of testing.

};

if f.sig.unsafety.is_none() {
if !matches!(f.sig.safety, syn::Safety::Unsafe(_)) {

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.

Function "safety" is now encoded with a 3-variant enum.

};

if f.sig.unsafety.is_none() {
if !matches!(f.sig.safety, syn::Safety::Unsafe(_)) {

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.

Function "safety" is now encoded with a 3-variant enum.

proc-macro2 = "1.0.106"
quote = "1.0.45"
syn = { version = "2.0.117", features = ["extra-traits", "full"] }
syn = { version = ">= 2.0.117, < 4", features = ["extra-traits", "full"] }

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.

cortex-m-macros seems to work with either syn v2 or v3: this allows both but, because cortex-m-rt-macros does depend on the v3 specifically, and as most dependents use both, you may prefer to depend on the v3 to simplify this a bit:

Suggested change
syn = { version = ">= 2.0.117, < 4", features = ["extra-traits", "full"] }
syn = { version = "3.0", features = ["extra-traits", "full"] }

Allowing both versions allows dependents that only depend on cortex-m-macros and don't otherwise have a (transitive) dependency on syn v3 to only use syn v2, thus avoiding the dependency duplication.

@AudaciousAxiom
AudaciousAxiom marked this pull request as ready for review August 5, 2026 08:10
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.

1 participant