mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 13:55:23 +01:00
fix: in edition 2024 link_section is used as unsafe(link_section = ...)
This commit is contained in:
parent
2c7dec32e4
commit
f61febf7a4
2 changed files with 26 additions and 8 deletions
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue