@@ -301,7 +301,6 @@ pub fn fields(
301301 let pc_r = & f. pc_r ;
302302 let mut pc_w = & f. pc_r ;
303303
304- let mut base_pc_w = None ;
305304 let mut evs_r = None ;
306305
307306 let _pc_r = & f. _pc_r ;
@@ -338,22 +337,17 @@ pub fn fields(
338337 }
339338 } ) ;
340339
341- base_pc_w = base . as_ref ( ) . map ( | base| {
340+ if let Some ( base ) = base {
342341 let pc = base. field . to_sanitized_upper_case ( ) ;
343342 let base_pc_r = Ident :: new ( & format ! ( "{}_A" , pc) , Span :: call_site ( ) ) ;
344- let base_pc_r =
345- derive_from_base ( mod_items, & base, & pc_r, & base_pc_r, description) ;
343+ derive_from_base ( mod_items, & base, & pc_r, & base_pc_r, description) ;
346344
347345 let doc = format ! ( "Reader of field `{}`" , f. name) ;
348346 mod_items. push ( quote ! {
349347 #[ doc = #doc]
350- pub type #_pc_r = crate :: R <#fty, #base_pc_r >;
348+ pub type #_pc_r = crate :: R <#fty, #pc_r >;
351349 } ) ;
352-
353- base_pc_r
354- } ) ;
355-
356- if base. is_none ( ) {
350+ } else {
357351 let has_reserved_variant = evs. values . len ( ) != ( 1 << f. width ) ;
358352 let variants = Variant :: from_enumerated_values ( evs) ?;
359353
@@ -474,13 +468,11 @@ pub fn fields(
474468 if Some ( evs) != evs_r. as_ref ( ) {
475469 pc_w = & f. pc_w ;
476470
477- base_pc_w = base . as_ref ( ) . map ( | base| {
471+ if let Some ( base ) = base {
478472 let pc = base. field . to_sanitized_upper_case ( ) ;
479473 let base_pc_w = Ident :: new ( & format ! ( "{}_AW" , pc) , Span :: call_site ( ) ) ;
480- derive_from_base ( mod_items, & base, & pc_w, & base_pc_w, description)
481- } ) ;
482-
483- if base. is_none ( ) {
474+ derive_from_base ( mod_items, & base, & pc_w, & base_pc_w, description) ;
475+ } else {
484476 add_from_variants ( mod_items, & variants, pc_w, & f, description, rv) ;
485477 }
486478 }
@@ -500,23 +492,13 @@ pub fn fields(
500492 let sc = & v. sc ;
501493
502494 let doc = util:: escape_brackets ( util:: respace ( & v. doc ) . as_ref ( ) ) ;
503- if let Some ( enum_) = base_pc_w. as_ref ( ) {
504- proxy_items. push ( quote ! {
505- #[ doc = #doc]
506- #[ inline( always) ]
507- pub fn #sc( self ) -> & ' a mut W {
508- self . variant( #enum_:: #pc)
509- }
510- } ) ;
511- } else {
512- proxy_items. push ( quote ! {
513- #[ doc = #doc]
514- #[ inline( always) ]
515- pub fn #sc( self ) -> & ' a mut W {
516- self . variant( #pc_w:: #pc)
517- }
518- } ) ;
519- }
495+ proxy_items. push ( quote ! {
496+ #[ doc = #doc]
497+ #[ inline( always) ]
498+ pub fn #sc( self ) -> & ' a mut W {
499+ self . variant( #pc_w:: #pc)
500+ }
501+ } ) ;
520502 }
521503 }
522504
@@ -694,7 +676,7 @@ fn derive_from_base(
694676 pc : & Ident ,
695677 base_pc : & Ident ,
696678 desc : & str ,
697- ) -> TokenStream {
679+ ) {
698680 let span = Span :: call_site ( ) ;
699681 if let ( Some ( peripheral) , Some ( register) ) = ( & base. peripheral , & base. register ) {
700682 let pmod_ = peripheral. to_sanitized_snake_case ( ) ;
@@ -707,10 +689,6 @@ fn derive_from_base(
707689 pub type #pc =
708690 crate :: #pmod_:: #rmod_:: #base_pc;
709691 } ) ;
710-
711- quote ! {
712- crate :: #pmod_:: #rmod_:: #base_pc
713- }
714692 } else if let Some ( register) = & base. register {
715693 let mod_ = register. to_sanitized_snake_case ( ) ;
716694 let mod_ = Ident :: new ( & mod_, span) ;
@@ -720,19 +698,11 @@ fn derive_from_base(
720698 pub type #pc =
721699 super :: #mod_:: #base_pc;
722700 } ) ;
723-
724- quote ! {
725- super :: #mod_:: #base_pc
726- }
727701 } else {
728702 mod_items. push ( quote ! {
729703 #[ doc = #desc]
730704 pub type #pc = #base_pc;
731705 } ) ;
732-
733- quote ! {
734- #base_pc
735- }
736706 }
737707}
738708
0 commit comments