@@ -113,20 +113,19 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
113
113
let vars = statics
114
114
. into_iter ( )
115
115
. map ( |var| {
116
+ let attrs = var. attrs ;
116
117
let ident = var. ident ;
117
- // `let` can't shadow a `static mut` so we must give the `static` a different
118
- // name. We'll create a new name by appending an underscore to the original name
119
- // of the `static`.
120
- let mut ident_ = ident. to_string ( ) ;
121
- ident_. push ( '_' ) ;
122
- let ident_ = Ident :: new ( & ident_, Span :: call_site ( ) ) ;
123
118
let ty = var. ty ;
124
119
let expr = var. expr ;
125
120
126
121
quote ! (
127
- static mut #ident_: #ty = #expr;
128
122
#[ allow( non_snake_case) ]
129
- let #ident: & ' static mut #ty = unsafe { & mut #ident_ } ;
123
+ let #ident: & ' static mut #ty = unsafe {
124
+ #( #attrs) *
125
+ static mut #ident: #ty = #expr;
126
+
127
+ & mut #ident
128
+ } ;
130
129
)
131
130
} ) . collect :: < Vec < _ > > ( ) ;
132
131
@@ -401,20 +400,19 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
401
400
let vars = statics
402
401
. into_iter ( )
403
402
. map ( |var| {
403
+ let attrs = var. attrs ;
404
404
let ident = var. ident ;
405
- // `let` can't shadow a `static mut` so we must give the `static` a different
406
- // name. We'll create a new name by appending an underscore to the original name
407
- // of the `static`.
408
- let mut ident_ = ident. to_string ( ) ;
409
- ident_. push ( '_' ) ;
410
- let ident_ = Ident :: new ( & ident_, Span :: call_site ( ) ) ;
411
405
let ty = var. ty ;
412
406
let expr = var. expr ;
413
407
414
408
quote ! (
415
- static mut #ident_: #ty = #expr;
416
409
#[ allow( non_snake_case) ]
417
- let #ident: & mut #ty = unsafe { & mut #ident_ } ;
410
+ let #ident: & mut #ty = unsafe {
411
+ #( #attrs) *
412
+ static mut #ident: #ty = #expr;
413
+
414
+ & mut #ident
415
+ } ;
418
416
)
419
417
} ) . collect :: < Vec < _ > > ( ) ;
420
418
@@ -545,20 +543,19 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
545
543
let vars = statics
546
544
. into_iter ( )
547
545
. map ( |var| {
546
+ let attrs = var. attrs ;
548
547
let ident = var. ident ;
549
- // `let` can't shadow a `static mut` so we must give the `static` a different
550
- // name. We'll create a new name by appending an underscore to the original name
551
- // of the `static`.
552
- let mut ident_ = ident. to_string ( ) ;
553
- ident_. push ( '_' ) ;
554
- let ident_ = Ident :: new ( & ident_, Span :: call_site ( ) ) ;
555
548
let ty = var. ty ;
556
549
let expr = var. expr ;
557
550
558
551
quote ! (
559
- static mut #ident_: #ty = #expr;
560
552
#[ allow( non_snake_case) ]
561
- let #ident: & mut #ty = unsafe { & mut #ident_ } ;
553
+ let #ident: & mut #ty = unsafe {
554
+ #( #attrs) *
555
+ static mut #ident: #ty = #expr;
556
+
557
+ & mut #ident
558
+ } ;
562
559
)
563
560
} ) . collect :: < Vec < _ > > ( ) ;
564
561
0 commit comments