From f6729db2e7004954606a020d8fb67a7589e679e5 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 21 Nov 2019 22:25:28 +0100 Subject: Re-allow `&'static mut` resources for `#[entry]` --- cortex-m-rt/macros/src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cortex-m-rt/macros/src') diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs index 052b075..b6b0fe4 100644 --- a/cortex-m-rt/macros/src/lib.rs +++ b/cortex-m-rt/macros/src/lib.rs @@ -115,8 +115,13 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { let ident = &statik.ident; let ty = &statik.ty; let attrs = &statik.attrs; - syn::parse::(quote!(#[allow(non_snake_case)] #(#attrs)* #ident: &mut #ty).into()) - .unwrap() + + // Note that we use an explicit `'static` lifetime for the entry point arguments. This makes + // it more flexible, and is sound here, since the entry will not be called again, ever. + syn::parse::( + quote!(#[allow(non_snake_case)] #(#attrs)* #ident: &'static mut #ty).into(), + ) + .unwrap() })); f.block.stmts = stmts; -- cgit v1.2.3