@@ -273,7 +273,6 @@ pub fn fields(
273
273
let pc_r = Ident :: new ( & ( pc. clone ( ) + "_A" ) , span) ;
274
274
let mut pc_w = & pc_r;
275
275
276
- let mut base_pc_w = None ;
277
276
let mut evs_r = None ;
278
277
279
278
if can_read {
@@ -306,22 +305,17 @@ pub fn fields(
306
305
}
307
306
} ) ;
308
307
309
- base_pc_w = base . as_ref ( ) . map ( | base| {
308
+ if let Some ( base ) = base {
310
309
let pc = base. field . to_sanitized_upper_case ( ) ;
311
310
let base_pc_r = Ident :: new ( & ( pc. clone ( ) + "_A" ) , span) ;
312
- let base_pc_r =
313
- derive_from_base ( mod_items, & base, & pc_r, & base_pc_r, & description) ;
311
+ derive_from_base ( mod_items, & base, & pc_r, & base_pc_r, & description) ;
314
312
315
313
let doc = format ! ( "Reader of field `{}`" , f. name) ;
316
314
mod_items. push ( quote ! {
317
315
#[ doc = #doc]
318
- pub type #_pc_r = crate :: R <#fty, #base_pc_r >;
316
+ pub type #_pc_r = crate :: R <#fty, #pc_r >;
319
317
} ) ;
320
-
321
- base_pc_r
322
- } ) ;
323
-
324
- if base. is_none ( ) {
318
+ } else {
325
319
let has_reserved_variant = evs. values . len ( ) != ( 1 << width) ;
326
320
let variants = Variant :: from_enumerated_values ( evs) ?;
327
321
@@ -441,14 +435,12 @@ pub fn fields(
441
435
442
436
if Some ( evs) != evs_r. as_ref ( ) {
443
437
pc_w = & new_pc_w;
444
- base_pc_w = base . as_ref ( ) . map ( | base| {
438
+ if let Some ( base ) = base {
445
439
let pc = base. field . to_sanitized_upper_case ( ) ;
446
440
let base_pc_w = Ident :: new ( & ( pc + "_AW" ) , span) ;
447
441
derive_from_base ( mod_items, & base, & pc_w, & base_pc_w, & description)
448
- } ) ;
449
-
450
- if base. is_none ( ) {
451
- add_from_variants ( mod_items, & variants, & pc_w, & fty, & description, rv) ;
442
+ } else {
443
+ add_from_variants ( mod_items, & variants, pc_w, & fty, & description, rv) ;
452
444
}
453
445
}
454
446
@@ -467,23 +459,13 @@ pub fn fields(
467
459
let sc = & v. sc ;
468
460
469
461
let doc = util:: escape_brackets ( util:: respace ( & v. doc ) . as_ref ( ) ) ;
470
- if let Some ( enum_) = base_pc_w. as_ref ( ) {
471
- proxy_items. push ( quote ! {
472
- #[ doc = #doc]
473
- #[ inline( always) ]
474
- pub fn #sc( self ) -> & ' a mut W {
475
- self . variant( #enum_:: #pc)
476
- }
477
- } ) ;
478
- } else {
479
- proxy_items. push ( quote ! {
480
- #[ doc = #doc]
481
- #[ inline( always) ]
482
- pub fn #sc( self ) -> & ' a mut W {
483
- self . variant( #pc_w:: #pc)
484
- }
485
- } ) ;
486
- }
462
+ proxy_items. push ( quote ! {
463
+ #[ doc = #doc]
464
+ #[ inline( always) ]
465
+ pub fn #sc( self ) -> & ' a mut W {
466
+ self . variant( #pc_w:: #pc)
467
+ }
468
+ } ) ;
487
469
}
488
470
}
489
471
@@ -658,7 +640,7 @@ fn derive_from_base(
658
640
pc : & Ident ,
659
641
base_pc : & Ident ,
660
642
desc : & str ,
661
- ) -> TokenStream {
643
+ ) {
662
644
let span = Span :: call_site ( ) ;
663
645
if let ( Some ( peripheral) , Some ( register) ) = ( & base. peripheral , & base. register ) {
664
646
let pmod_ = peripheral. to_sanitized_snake_case ( ) ;
@@ -671,10 +653,6 @@ fn derive_from_base(
671
653
pub type #pc =
672
654
crate :: #pmod_:: #rmod_:: #base_pc;
673
655
} ) ;
674
-
675
- quote ! {
676
- crate :: #pmod_:: #rmod_:: #base_pc
677
- }
678
656
} else if let Some ( register) = & base. register {
679
657
let mod_ = register. to_sanitized_snake_case ( ) ;
680
658
let mod_ = Ident :: new ( & mod_, span) ;
@@ -684,19 +662,11 @@ fn derive_from_base(
684
662
pub type #pc =
685
663
super :: #mod_:: #base_pc;
686
664
} ) ;
687
-
688
- quote ! {
689
- super :: #mod_:: #base_pc
690
- }
691
665
} else {
692
666
mod_items. push ( quote ! {
693
667
#[ doc = #desc]
694
668
pub type #pc = #base_pc;
695
669
} ) ;
696
-
697
- quote ! {
698
- #base_pc
699
- }
700
670
}
701
671
}
702
672
0 commit comments