Skip to content

Commit 06b4b40

Browse files
Merge branch 'main' into leighleighleigh/s2-s3-wake-hp-core
2 parents 74fdba5 + b1729b8 commit 06b4b40

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

esp-hal-procmacros/src/interrupt.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ pub fn check_attr_whitelist(
138138
];
139139

140140
'o: for attr in attrs {
141-
for val in whitelist {
142-
if eq(attr, val) {
141+
if let Some(attr_name) = get_attr_name(attr) {
142+
if whitelist.contains(&attr_name.as_str()) {
143143
continue 'o;
144144
}
145145
}
@@ -156,9 +156,25 @@ pub fn check_attr_whitelist(
156156
Ok(())
157157
}
158158

159-
/// Returns `true` if `attr.path` matches `name`
160-
fn eq(attr: &Attribute, name: &str) -> bool {
161-
attr.style == AttrStyle::Outer && attr.path().is_ident(name)
159+
/// Extracts the base name of an attribute, including unwrapping of `#[unsafe(...)]`.
160+
fn get_attr_name(attr: &Attribute) -> Option<String> {
161+
if !matches!(attr.style, AttrStyle::Outer) {
162+
return None;
163+
}
164+
165+
let name = attr.path().get_ident().map(|x| x.to_string());
166+
167+
match &name {
168+
Some(name) if name == "unsafe" => {
169+
// Try to parse the inner meta of #[unsafe(...)]
170+
if let Ok(inner_meta) = attr.parse_args::<syn::Meta>() {
171+
inner_meta.path().get_ident().map(|x| x.to_string())
172+
} else {
173+
None
174+
}
175+
}
176+
_ => name,
177+
}
162178
}
163179

164180
#[cfg(test)]

esp-hal/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@
1515
//! . Please ensure you are reading the correct [documentation] for your target
1616
//! device.
1717
//!
18-
//! ## Choosing a Device
19-
//!
20-
//! Depending on your target device, you need to enable the chip feature
21-
//! for that device. You may also need to do this on ancillary esp-hal crates.
22-
//!
2318
//! ## Overview
2419
//!
20+
//! esp-hal is a Hardware Abstraction Layer (HAL) for Espressif's ESP32 lineup of
21+
//! microcontrollers offering safe, idiotmatic APIs to control hardware peripherals.
22+
//!
2523
//! ### Peripheral drivers
2624
//!
27-
//! The HAL implements both blocking _and_ async APIs for many peripherals.
25+
//! The HAL implements both [`Blocking`] _and_ [`Async`] APIs for all applicable peripherals.
2826
//! Where applicable, driver implement the [embedded-hal] and
29-
//! [embedded-hal-async] traits.
27+
//! [embedded-hal-async] traits. Drivers that don't currently have a stable API
28+
//! are marked as `unstable` in the documentation.
3029
//!
3130
//! ### Peripheral singletons
3231
//!
@@ -89,7 +88,7 @@
8988
//!
9089
//! ## Creating a Project
9190
//!
92-
//! We have a [book] that explains the full esp-rs ecosystem
91+
//! We have a [book] that explains the full esp-hal ecosystem
9392
//! and how to get started, it's advisable to give that a read
9493
//! before proceeding. We also have a [training] that covers some common
9594
//! scenarios with examples.
@@ -154,9 +153,9 @@
154153
#![doc = ""]
155154
//! ## Don't use `core::mem::forget`
156155
//!
157-
//! You should never use `core::mem::forget` on any type defined in the HAL.
158-
//! Some types heavily rely on their `Drop` implementation to not leave the
159-
//! hardware in undefined state and causing UB.
156+
//! You should never use `core::mem::forget` on any type defined in [esp crates].
157+
//! Many types heavily rely on their `Drop` implementation to not leave the
158+
//! hardware in undefined state which can cause undefined behaviour in your program.
160159
//!
161160
//! You might want to consider using [`#[deny(clippy::mem_forget)`](https://rust-lang.github.io/rust-clippy/v0.0.212/index.html#mem_forget) in your project.
162161
//!
@@ -185,6 +184,7 @@
185184
//! [esp-generate]: https://github.com/esp-rs/esp-generate
186185
//! [book]: https://docs.espressif.com/projects/rust/book/
187186
//! [training]: https://docs.espressif.com/projects/rust/no_std-training/
187+
//! [esp crates]: https://docs.espressif.com/projects/rust/book/introduction/ancillary-crates.html#esp-hal-ecosystem
188188
//!
189189
//! ## Feature Flags
190190
#![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)]

0 commit comments

Comments
 (0)