Skip to content

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

Merged
therealprof merged 2 commits into
rust-embedded:masterfrom
AudaciousAxiom:refactor/syn-v3
Sep 3, 2026
Merged

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

Conversation

@AudaciousAxiom

Copy link
Copy Markdown
Contributor

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
Contributor 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
Contributor 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.

Comment thread cortex-m/macros/Cargo.toml Outdated
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
Contributor 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a big pro of the simpler 3.0 dep is that it's far less likely to break something by accident. If someone accidentally uses a 3.0 feature without updating the syn dep, you're breaking everyone with syn 2 in their lock files.
Not worth it IMO

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! I've simplified to just list syn v3.

@AudaciousAxiom
AudaciousAxiom marked this pull request as ready for review August 5, 2026 08:10

@diondokter diondokter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, though see my thoughts on the syn version

@therealprof therealprof left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@therealprof
therealprof added this pull request to the merge queue Sep 3, 2026
Merged via the queue into rust-embedded:master with commit 941034a Sep 3, 2026
11 checks passed
@AudaciousAxiom
AudaciousAxiom deleted the refactor/syn-v3 branch September 3, 2026 14:49
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.

4 participants