Skip to content

Commit 89ba8f6

Browse files
authored
Update esp-hal-procmacros package dependencies and features (#628)
* Remove unnecessary `riscv` and `xtensa` features from proc macro crate * Update `darling` and `syn`, address breaking changes * Update CHANGELOG * Remove unneeded macro definition/invocation
1 parent 2371c30 commit 89ba8f6

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4242
- Re-work `RadioExt` implementations, add support for ESP32-H2 (#627)
4343
- Improve examples documentation (#533)
4444
- esp32h2-hal: added README (#585)
45+
- Update `esp-hal-procmacros` package dependencies and features (#628)
4546

4647
### Fixed
4748

esp-hal-common/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ embassy-time-timg0 = []
105105
interrupt-preemption = []
106106

107107
# Architecture-specific features (intended for internal use)
108-
riscv = ["critical-section/restore-state-u8", "procmacros/riscv", "esp-riscv-rt", "riscv-atomic-emulation-trap", "esp-riscv-rt/zero-bss"]
109-
xtensa = ["critical-section/restore-state-u32", "procmacros/xtensa"]
108+
riscv = ["critical-section/restore-state-u8", "esp-riscv-rt", "esp-riscv-rt/zero-bss", "riscv-atomic-emulation-trap"]
109+
xtensa = ["critical-section/restore-state-u32"]
110110

111111
# Initialize / clear data sections and RTC memory
112112
rv-init-data = ["esp-riscv-rt/init-data", "esp-riscv-rt/init-rw-text"]

esp-hal-procmacros/Cargo.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,27 @@ repository = "https://github.com/esp-rs/esp-hal"
1212
license = "MIT OR Apache-2.0"
1313

1414
[package.metadata.docs.rs]
15-
features = ["esp32c3", "interrupt", "riscv"]
15+
features = ["esp32c3", "interrupt"]
1616

1717
[lib]
1818
proc-macro = true
1919

2020
[dependencies]
21-
darling = "0.14.4"
21+
darling = "0.20.1"
2222
proc-macro-crate = "1.3.1"
2323
proc-macro-error = "1.0.4"
2424
proc-macro2 = "1.0.53"
2525
quote = "1.0.26"
26-
syn = {version = "1.0.109", features = ["extra-traits", "full"]}
26+
syn = {version = "2.0.22", features = ["extra-traits", "full"]}
2727

2828
[features]
29-
interrupt = []
30-
riscv = []
31-
rtc_slow = []
32-
xtensa = []
3329
esp32 = []
3430
esp32c2 = []
3531
esp32c3 = []
3632
esp32c6 = []
3733
esp32h2 = []
3834
esp32s2 = []
3935
esp32s3 = []
36+
37+
interrupt = []
38+
rtc_slow = []

esp-hal-procmacros/src/lib.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/46717278")]
55

6-
use darling::FromMeta;
6+
use darling::{ast::NestedMeta, FromMeta};
77
use proc_macro::{self, Span, TokenStream};
88
use proc_macro_error::{abort, proc_macro_error};
99
use quote::quote;
@@ -23,7 +23,6 @@ use syn::{
2323
use syn::{
2424
parse::{Parse, ParseStream},
2525
parse_macro_input,
26-
AttributeArgs,
2726
};
2827

2928
#[derive(Debug, Default, FromMeta)]
@@ -47,7 +46,12 @@ struct RamArgs {
4746
#[proc_macro_attribute]
4847
#[proc_macro_error]
4948
pub fn ram(args: TokenStream, input: TokenStream) -> TokenStream {
50-
let attr_args = parse_macro_input!(args as AttributeArgs);
49+
let attr_args = match NestedMeta::parse_meta_list(args.into()) {
50+
Ok(v) => v,
51+
Err(e) => {
52+
return TokenStream::from(darling::Error::from(e).write_errors());
53+
}
54+
};
5155

5256
let RamArgs {
5357
rtc_fast,
@@ -142,7 +146,12 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
142146

143147
let mut f: ItemFn = syn::parse(input).expect("`#[interrupt]` must be applied to a function");
144148

145-
let attr_args = parse_macro_input!(args as AttributeArgs);
149+
let attr_args = match NestedMeta::parse_meta_list(args.into()) {
150+
Ok(v) => v,
151+
Err(e) => {
152+
return TokenStream::from(darling::Error::from(e).write_errors());
153+
}
154+
};
146155

147156
if attr_args.len() > 1 {
148157
abort!(
@@ -156,7 +165,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
156165

157166
if attr_args.len() == 1 {
158167
match &attr_args[0] {
159-
syn::NestedMeta::Meta(Path(x)) => {
168+
NestedMeta::Meta(Path(x)) => {
160169
ident_s = x.get_ident().unwrap();
161170
}
162171
_ => {
@@ -285,12 +294,6 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
285294
(f.sig.inputs.len() == 1).then(|| Ident::new("context", proc_macro2::Span::call_site()));
286295

287296
quote!(
288-
macro_rules! foo {
289-
() => {
290-
};
291-
}
292-
foo!();
293-
294297
#(#cfgs)*
295298
#(#attrs)*
296299
#[doc(hidden)]
@@ -351,7 +354,7 @@ fn check_attr_whitelist(attrs: &[Attribute], caller: WhiteListCaller) -> Result<
351354
/// Returns `true` if `attr.path` matches `name`
352355
#[cfg(feature = "interrupt")]
353356
fn eq(attr: &Attribute, name: &str) -> bool {
354-
attr.style == AttrStyle::Outer && attr.path.is_ident(name)
357+
attr.style == AttrStyle::Outer && attr.path().is_ident(name)
355358
}
356359

357360
#[cfg(feature = "interrupt")]

0 commit comments

Comments
 (0)