Skip to content

Commit f6729db

Browse files
Re-allow &'static mut resources for #[entry]
1 parent d5fce0d commit f6729db

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cortex-m-rt/macros/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,13 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
115115
let ident = &statik.ident;
116116
let ty = &statik.ty;
117117
let attrs = &statik.attrs;
118-
syn::parse::<FnArg>(quote!(#[allow(non_snake_case)] #(#attrs)* #ident: &mut #ty).into())
119-
.unwrap()
118+
119+
// Note that we use an explicit `'static` lifetime for the entry point arguments. This makes
120+
// it more flexible, and is sound here, since the entry will not be called again, ever.
121+
syn::parse::<FnArg>(
122+
quote!(#[allow(non_snake_case)] #(#attrs)* #ident: &'static mut #ty).into(),
123+
)
124+
.unwrap()
120125
}));
121126
f.block.stmts = stmts;
122127

0 commit comments

Comments
 (0)