diff options
| author | Oleksandr Babak <alexanderbabak@proton.me> | 2025-04-13 21:16:16 +0200 |
|---|---|---|
| committer | Emil Fresk <emil.fresk@gmail.com> | 2025-06-18 18:49:41 +0000 |
| commit | f61febf7a4526b35d43626d9d363de21f8d33fd9 (patch) | |
| tree | 242bf1c65969a6409f975b575933520fa1c451c9 /rtic-macros/src | |
| parent | 2c7dec32e4aa3a248d5264a57f01dd6ca0d82057 (diff) | |
fix: in edition 2024 `link_section` is used as `unsafe(link_section = ...)`
Diffstat (limited to 'rtic-macros/src')
| -rw-r--r-- | rtic-macros/src/codegen/local_resources.rs | 17 | ||||
| -rw-r--r-- | rtic-macros/src/codegen/shared_resources.rs | 17 |
2 files changed, 26 insertions, 8 deletions
diff --git a/rtic-macros/src/codegen/local_resources.rs b/rtic-macros/src/codegen/local_resources.rs index c73ad56..86dda86 100644 --- a/rtic-macros/src/codegen/local_resources.rs +++ b/rtic-macros/src/codegen/local_resources.rs @@ -19,10 +19,19 @@ pub fn codegen(app: &App, _analysis: &Analysis) -> TokenStream2 { // late resources in `util::link_section_uninit` // unless user specifies custom link section - let section = if attrs - .iter() - .any(|attr| attr.path().is_ident("link_section")) - { + let section = if attrs.iter().any(|attr| { + let is_link_section = attr.path().is_ident("link_section"); + let is_unsafe = attr.path().is_ident("unsafe"); + let is_embedded_link_section = match attr.parse_args() { + Ok(syn::Expr::Assign(assign)) => match &*assign.left { + syn::Expr::Path(path) => path.path.is_ident("link_section"), + _ => false, + }, + _ => false, + }; + + is_link_section || (is_unsafe && is_embedded_link_section) + }) { None } else { Some(util::link_section_uninit()) diff --git a/rtic-macros/src/codegen/shared_resources.rs b/rtic-macros/src/codegen/shared_resources.rs index d89f0c2..5e8ca9a 100644 --- a/rtic-macros/src/codegen/shared_resources.rs +++ b/rtic-macros/src/codegen/shared_resources.rs @@ -19,10 +19,19 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 { // late resources in `util::link_section_uninit` // unless user specifies custom link section - let section = if attrs - .iter() - .any(|attr| attr.path().is_ident("link_section")) - { + let section = if attrs.iter().any(|attr| { + let is_link_section = attr.path().is_ident("link_section"); + let is_unsafe = attr.path().is_ident("unsafe"); + let is_embedded_link_section = match attr.parse_args() { + Ok(syn::Expr::Assign(assign)) => match &*assign.left { + syn::Expr::Path(path) => path.path.is_ident("link_section"), + _ => false, + }, + _ => false, + }; + + is_link_section || (is_unsafe && is_embedded_link_section) + }) { None } else { Some(util::link_section_uninit()) |
