aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Schievink <jonasschievink@gmail.com> 2019-11-21 22:25:28 +0100
committerGravatar Jonas Schievink <jonasschievink@gmail.com> 2019-11-21 22:27:44 +0100
commitf6729db2e7004954606a020d8fb67a7589e679e5 (patch)
tree29f5ec6b053db3719296fdae1866a69094674a1d
parentd5fce0daaef5c02ab18cd084611cf6f82351f79d (diff)
downloadcortex-m-f6729db2e7004954606a020d8fb67a7589e679e5.tar.gz
cortex-m-f6729db2e7004954606a020d8fb67a7589e679e5.tar.zst
cortex-m-f6729db2e7004954606a020d8fb67a7589e679e5.zip
Re-allow `&'static mut` resources for `#[entry]`
-rw-r--r--cortex-m-rt/macros/src/lib.rs9
1 files changed, 7 insertions, 2 deletions
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::<FnArg>(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::<FnArg>(
+ quote!(#[allow(non_snake_case)] #(#attrs)* #ident: &'static mut #ty).into(),
+ )
+ .unwrap()
}));
f.block.stmts = stmts;