1+ use crate :: quote:: ToTokens ;
12use crate :: svd:: {
23 Access , BitRange , EnumeratedValues , Field , Peripheral , Register , RegisterCluster ,
34 RegisterProperties , Usage , WriteConstraint ,
@@ -122,9 +123,7 @@ pub fn render(
122123
123124 mod_items. extend ( r_impl_items) ;
124125
125- mod_items. extend ( quote ! {
126- #close
127- } ) ;
126+ close. to_tokens ( & mut mod_items) ;
128127 }
129128
130129 if can_write {
@@ -134,9 +133,7 @@ pub fn render(
134133
135134 mod_items. extend ( w_impl_items) ;
136135
137- mod_items. extend ( quote ! {
138- #close
139- } ) ;
136+ close. to_tokens ( & mut mod_items) ;
140137 }
141138
142139 let mut out = TokenStream :: new ( ) ;
@@ -216,6 +213,7 @@ pub fn fields(
216213 let can_write = access != Access :: ReadOnly ;
217214
218215 // TODO enumeratedValues
216+ let inline = quote ! { #[ inline( always) ] } ;
219217 for f in fields. iter ( ) {
220218 // TODO(AJM) - do we need to do anything with this range type?
221219 let BitRange { offset, width, .. } = f. bit_range ;
@@ -317,7 +315,7 @@ pub fn fields(
317315 let doc = & util:: replace_suffix ( & description, suffixes_str) ;
318316 r_impl_items. extend ( quote ! {
319317 #[ doc = #doc]
320- #[ inline( always ) ]
318+ #inline
321319 pub unsafe fn #sc( & self , n: usize ) -> #_pc_r {
322320 #_pc_r:: new ( #value )
323321 }
@@ -344,7 +342,7 @@ pub fn fields(
344342 ) ;
345343 r_impl_items. extend ( quote ! {
346344 #[ doc = #doc]
347- #[ inline( always ) ]
345+ #inline
348346 pub fn #sc_n( & self ) -> #_pc_r {
349347 #_pc_r:: new ( #value )
350348 }
@@ -354,7 +352,7 @@ pub fn fields(
354352 let doc = description_with_bits ( & description, offset, width) ;
355353 r_impl_items. extend ( quote ! {
356354 #[ doc = #doc]
357- #[ inline( always ) ]
355+ #inline
358356 pub fn #sc( & self ) -> #_pc_r {
359357 #_pc_r:: new ( #value )
360358 }
@@ -410,7 +408,7 @@ pub fn fields(
410408 if has_reserved_variant {
411409 enum_items. extend ( quote ! {
412410 ///Get enumerated values variant
413- #[ inline( always ) ]
411+ #inline
414412 pub fn variant( & self ) -> crate :: Variant <#fty, #pc_r> {
415413 use crate :: Variant :: * ;
416414 match self . bits {
@@ -421,7 +419,7 @@ pub fn fields(
421419 } else {
422420 enum_items. extend ( quote ! {
423421 ///Get enumerated values variant
424- #[ inline( always ) ]
422+ #inline
425423 pub fn variant( & self ) -> #pc_r {
426424 match self . bits {
427425 #arms
@@ -446,7 +444,7 @@ pub fn fields(
446444 let doc = format ! ( "Checks if the value of the field is `{}`" , pc) ;
447445 enum_items. extend ( quote ! {
448446 #[ doc = #doc]
449- #[ inline( always ) ]
447+ #inline
450448 pub fn #is_variant( & self ) -> bool {
451449 * self == #pc_r:: #pc
452450 }
@@ -499,7 +497,7 @@ pub fn fields(
499497
500498 proxy_items. extend ( quote ! {
501499 ///Writes `variant` to the field
502- #[ inline( always ) ]
500+ #inline
503501 pub fn variant( self , variant: #pc_w) -> & ' a mut W {
504502 #unsafety {
505503 self . #bits( variant. into( ) )
@@ -514,7 +512,7 @@ pub fn fields(
514512 let doc = util:: escape_brackets ( util:: respace ( & v. doc ) . as_ref ( ) ) ;
515513 proxy_items. extend ( quote ! {
516514 #[ doc = #doc]
517- #[ inline( always ) ]
515+ #inline
518516 pub fn #sc( self ) -> & ' a mut W {
519517 self . variant( #pc_w:: #pc)
520518 }
@@ -525,13 +523,13 @@ pub fn fields(
525523 if width == 1 {
526524 proxy_items. extend ( quote ! {
527525 ///Sets the field bit
528- #[ inline( always ) ]
526+ #inline
529527 pub #unsafety fn set_bit( self ) -> & ' a mut W {
530528 self . bit( true )
531529 }
532530
533531 ///Clears the field bit
534- #[ inline( always ) ]
532+ #inline
535533 pub #unsafety fn clear_bit( self ) -> & ' a mut W {
536534 self . bit( false )
537535 }
@@ -541,7 +539,7 @@ pub fn fields(
541539 proxy_items. extend ( if field_dim. is_some ( ) {
542540 quote ! {
543541 ///Writes raw bits to the field
544- #[ inline( always ) ]
542+ #inline
545543 pub #unsafety fn #bits( self , value: #fty) -> & ' a mut W {
546544 self . w. bits = ( self . w. bits & !( #hexmask << self . offset) ) | ( ( ( value as #rty) & #hexmask) << self . offset) ;
547545 self . w
@@ -551,7 +549,7 @@ pub fn fields(
551549 let offset = & util:: unsuffixed ( offset) ;
552550 quote ! {
553551 ///Writes raw bits to the field
554- #[ inline( always ) ]
552+ #inline
555553 pub #unsafety fn #bits( self , value: #fty) -> & ' a mut W {
556554 self . w. bits = ( self . w. bits & !( #hexmask << #offset) ) | ( ( ( value as #rty) & #hexmask) << #offset) ;
557555 self . w
@@ -560,7 +558,7 @@ pub fn fields(
560558 } else {
561559 quote ! {
562560 ///Writes raw bits to the field
563- #[ inline( always ) ]
561+ #inline
564562 pub #unsafety fn #bits( self , value: #fty) -> & ' a mut W {
565563 self . w. bits = ( self . w. bits & !#hexmask) | ( ( value as #rty) & #hexmask) ;
566564 self . w
@@ -594,7 +592,7 @@ pub fn fields(
594592 let doc = & util:: replace_suffix ( & description, suffixes_str) ;
595593 w_impl_items. extend ( quote ! {
596594 #[ doc = #doc]
597- #[ inline( always ) ]
595+ #inline
598596 pub unsafe fn #sc( & mut self , n: usize ) -> #_pc_w {
599597 #_pc_w { w: self , offset: #offset_calc }
600598 }
@@ -612,7 +610,7 @@ pub fn fields(
612610 let sub_offset = util:: unsuffixed ( sub_offset as u64 ) ;
613611 w_impl_items. extend ( quote ! {
614612 #[ doc = #doc]
615- #[ inline( always ) ]
613+ #inline
616614 pub fn #sc_n( & mut self ) -> #_pc_w {
617615 #_pc_w { w: self , offset: #sub_offset }
618616 }
@@ -622,7 +620,7 @@ pub fn fields(
622620 let doc = description_with_bits ( & description, offset, width) ;
623621 w_impl_items. extend ( quote ! {
624622 #[ doc = #doc]
625- #[ inline( always ) ]
623+ #inline
626624 pub fn #sc( & mut self ) -> #_pc_w {
627625 #_pc_w { w: self }
628626 }
0 commit comments