aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/macros/src/lib.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2018-10-26 20:39:39 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2018-10-26 20:39:39 +0200
commit58cdad2fba9763ac590bb0460ecd7193014a1e12 (patch)
tree7fbb869c1dc8898c8d985b1e00fb0506e9b99f1a /cortex-m-rt/macros/src/lib.rs
parentac9c05361cfbe46ace2162a3985e4660610747aa (diff)
downloadcortex-m-58cdad2fba9763ac590bb0460ecd7193014a1e12.tar.gz
cortex-m-58cdad2fba9763ac590bb0460ecd7193014a1e12.tar.zst
cortex-m-58cdad2fba9763ac590bb0460ecd7193014a1e12.zip
entry/exception/interrupt: reduce namespace pollution when using static mut
this changes code generation of code like this: ``` rust #[entry] fn main() -> ! { static mut FOO: u32 = 0; // .. } ``` from this: ``` rust fn main() -> ! { static mut FOO_: u32 = 0; let FOO: &'static mut u32 = unsafe { &mut FOO_ }; // .. } ``` to this: ``` rust fn main() -> ! { let FOO: &'static mut u32 = unsafe { static mut FOO: u32 = 0; &mut FOO; }; // .. } ``` this completely hides the `static mut` variable. Before it was possible to (unsafely) access it via `${ident}_` (e.g. `FOO_`).
Diffstat (limited to 'cortex-m-rt/macros/src/lib.rs')
-rw-r--r--cortex-m-rt/macros/src/lib.rs39
1 files changed, 15 insertions, 24 deletions
diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs
index 56ec88c..560a05f 100644
--- a/cortex-m-rt/macros/src/lib.rs
+++ b/cortex-m-rt/macros/src/lib.rs
@@ -114,19 +114,16 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
.into_iter()
.map(|var| {
let ident = var.ident;
- // `let` can't shadow a `static mut` so we must give the `static` a different
- // name. We'll create a new name by appending an underscore to the original name
- // of the `static`.
- let mut ident_ = ident.to_string();
- ident_.push('_');
- let ident_ = Ident::new(&ident_, Span::call_site());
let ty = var.ty;
let expr = var.expr;
quote!(
- static mut #ident_: #ty = #expr;
#[allow(non_snake_case)]
- let #ident: &'static mut #ty = unsafe { &mut #ident_ };
+ let #ident: &'static mut #ty = unsafe {
+ static mut #ident: #ty = #expr;
+
+ &mut #ident
+ };
)
}).collect::<Vec<_>>();
@@ -402,19 +399,16 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
.into_iter()
.map(|var| {
let ident = var.ident;
- // `let` can't shadow a `static mut` so we must give the `static` a different
- // name. We'll create a new name by appending an underscore to the original name
- // of the `static`.
- let mut ident_ = ident.to_string();
- ident_.push('_');
- let ident_ = Ident::new(&ident_, Span::call_site());
let ty = var.ty;
let expr = var.expr;
quote!(
- static mut #ident_: #ty = #expr;
#[allow(non_snake_case)]
- let #ident: &mut #ty = unsafe { &mut #ident_ };
+ let #ident: &mut #ty = unsafe {
+ static mut #ident: #ty = #expr;
+
+ &mut #ident
+ };
)
}).collect::<Vec<_>>();
@@ -546,19 +540,16 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
.into_iter()
.map(|var| {
let ident = var.ident;
- // `let` can't shadow a `static mut` so we must give the `static` a different
- // name. We'll create a new name by appending an underscore to the original name
- // of the `static`.
- let mut ident_ = ident.to_string();
- ident_.push('_');
- let ident_ = Ident::new(&ident_, Span::call_site());
let ty = var.ty;
let expr = var.expr;
quote!(
- static mut #ident_: #ty = #expr;
#[allow(non_snake_case)]
- let #ident: &mut #ty = unsafe { &mut #ident_ };
+ let #ident: &mut #ty = unsafe {
+ static mut #ident: #ty = #expr;
+
+ &mut #ident
+ };
)
}).collect::<Vec<_>>();
ocket-upgrade&id=bb9933fa7ec5eafcb8ef902c96d85a2b248a85be'>treecommitdiff
path: root/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CTR.h (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-10-07Exclude more filesGravatar Jarred Sumner 1-1/+2
2023-10-07Update settings.jsonGravatar Jarred Sumner 1-1/+2
2023-10-07Update settings.jsonGravatar Jarred Sumner 1-2/+3
2023-10-06fix a couple install testsGravatar Dylan Conway 1-8/+8
2023-10-06formatGravatar Dylan Conway 1-1/+2
2023-10-06Fix memory leak in fetch() (#6350)Gravatar Jarred Sumner 1-2/+0
2023-10-06[types] allow onLoad plugin callbacks to return undefined (#6346)Gravatar Silver 1-1/+1
2023-10-06docs: `file.stream()` is not a promise (#6337)Gravatar Paul Nodet 1-1/+1