Skip to content
Open
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
2 changes: 1 addition & 1 deletion cortex-m-rt/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ proc-macro2 = "1.0"

[dependencies.syn]
features = ["extra-traits", "full"]
version = "2.0"
version = "3.0"
4 changes: 2 additions & 2 deletions cortex-m-rt/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
}
};

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.

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.

match exn {
Exception::DefaultHandler | Exception::HardFault(_) | Exception::NonMaskableInt => {
// These are unsafe to define.
Expand Down Expand Up @@ -635,7 +635,7 @@ pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
// check the function signature
let valid_signature = f.sig.constness.is_none()
&& f.vis == Visibility::Inherited
&& f.sig.unsafety.is_some()
&& matches!(f.sig.safety, syn::Safety::Unsafe(_))
&& f.sig.abi.is_none()
&& f.sig.inputs.is_empty()
&& f.sig.generics.params.is_empty()
Expand Down
2 changes: 1 addition & 1 deletion cortex-m/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ proc-macro = true
[dependencies]
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.


[dev-dependencies]
macrotest = "1.2.1"
Expand Down