@@ -301,7 +301,6 @@ pub fn fields(
301
301
let pc_r = & f. pc_r ;
302
302
let mut pc_w = & f. pc_r ;
303
303
304
- let mut base_pc_w = None ;
305
304
let mut evs_r = None ;
306
305
307
306
let _pc_r = & f. _pc_r ;
@@ -338,22 +337,17 @@ pub fn fields(
338
337
}
339
338
} ) ;
340
339
341
- base_pc_w = base . as_ref ( ) . map ( | base| {
340
+ if let Some ( base ) = base {
342
341
let pc = base. field . to_sanitized_upper_case ( ) ;
343
342
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) ;
346
344
347
345
let doc = format ! ( "Reader of field `{}`" , f. name) ;
348
346
mod_items. push ( quote ! {
349
347
#[ doc = #doc]
350
- pub type #_pc_r = crate :: R <#fty, #base_pc_r >;
348
+ pub type #_pc_r = crate :: R <#fty, #pc_r >;
351
349
} ) ;
352
-
353
- base_pc_r
354
- } ) ;
355
-
356
- if base. is_none ( ) {
350
+ } else {
357
351
let has_reserved_variant = evs. values . len ( ) != ( 1 << f. width ) ;
358
352
let variants = Variant :: from_enumerated_values ( evs) ?;
359
353
@@ -474,13 +468,11 @@ pub fn fields(
474
468
if Some ( evs) != evs_r. as_ref ( ) {
475
469
pc_w = & f. pc_w ;
476
470
477
- base_pc_w = base . as_ref ( ) . map ( | base| {
471
+ if let Some ( base ) = base {
478
472
let pc = base. field . to_sanitized_upper_case ( ) ;
479
473
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 {
484
476
add_from_variants ( mod_items, & variants, pc_w, & f, description, rv) ;
485
477
}
486
478
}
@@ -500,23 +492,13 @@ pub fn fields(
500
492
let sc = & v. sc ;
501
493
502
494
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
+ } ) ;
520
502
}
521
503
}
522
504
@@ -694,7 +676,7 @@ fn derive_from_base(
694
676
pc : & Ident ,
695
677
base_pc : & Ident ,
696
678
desc : & str ,
697
- ) -> TokenStream {
679
+ ) {
698
680
let span = Span :: call_site ( ) ;
699
681
if let ( Some ( peripheral) , Some ( register) ) = ( & base. peripheral , & base. register ) {
700
682
let pmod_ = peripheral. to_sanitized_snake_case ( ) ;
@@ -707,10 +689,6 @@ fn derive_from_base(
707
689
pub type #pc =
708
690
crate :: #pmod_:: #rmod_:: #base_pc;
709
691
} ) ;
710
-
711
- quote ! {
712
- crate :: #pmod_:: #rmod_:: #base_pc
713
- }
714
692
} else if let Some ( register) = & base. register {
715
693
let mod_ = register. to_sanitized_snake_case ( ) ;
716
694
let mod_ = Ident :: new ( & mod_, span) ;
@@ -720,19 +698,11 @@ fn derive_from_base(
720
698
pub type #pc =
721
699
super :: #mod_:: #base_pc;
722
700
} ) ;
723
-
724
- quote ! {
725
- super :: #mod_:: #base_pc
726
- }
727
701
} else {
728
702
mod_items. push ( quote ! {
729
703
#[ doc = #desc]
730
704
pub type #pc = #base_pc;
731
705
} ) ;
732
-
733
- quote ! {
734
- #base_pc
735
- }
736
706
}
737
707
}
738
708
0 commit comments