@@ -606,7 +606,6 @@ pub fn fields(
606
606
if can_write {
607
607
let new_pc_aw = Ident :: new ( & ( name_pc. clone ( ) + "_AW" ) , span) ;
608
608
let name_pc_w = Ident :: new ( & ( name_pc. clone ( ) + "_W" ) , span) ;
609
- let name_pc_cgw = Ident :: new ( & ( name_pc. clone ( ) + "_CGW" ) , span) ;
610
609
611
610
let mut proxy_items = TokenStream :: new ( ) ;
612
611
let mut unsafety = unsafety ( f. write_constraint . as_ref ( ) , width) ;
@@ -752,27 +751,27 @@ pub fn fields(
752
751
} ;
753
752
754
753
if field_dim. is_some ( ) {
755
- mod_items. extend ( quote ! {
756
- #[ doc = #doc]
757
- pub struct #name_pc_w<' a> {
758
- w: & ' a mut W ,
759
- offset: usize ,
760
- }
761
-
762
- impl <' a> #name_pc_w<' a> {
763
- #proxy_items
764
- #proxy_items_fa
765
- }
766
- } ) ;
754
+ if !config. const_generic {
755
+ mod_items. extend ( quote ! {
756
+ #[ doc = #doc]
757
+ pub struct #name_pc_w<' a> {
758
+ w: & ' a mut W ,
759
+ offset: usize ,
760
+ }
767
761
768
- if config. const_generic {
762
+ impl <' a> #name_pc_w<' a> {
763
+ #proxy_items
764
+ #proxy_items_fa
765
+ }
766
+ } ) ;
767
+ } else {
769
768
mod_items. extend ( quote ! {
770
769
#[ doc = #cgdoc]
771
- pub struct #name_pc_cgw <' a, const O : usize > {
770
+ pub struct #name_pc_w <' a, const O : usize > {
772
771
w: & ' a mut W ,
773
772
}
774
773
775
- impl <' a, const O : usize > #name_pc_cgw <' a, O > {
774
+ impl <' a, const O : usize > #name_pc_w <' a, O > {
776
775
#proxy_items
777
776
#proxy_items_cg
778
777
}
@@ -792,15 +791,25 @@ pub fn fields(
792
791
}
793
792
794
793
if let Some ( ( first, dim, increment, suffixes, suffixes_str) ) = & field_dim {
795
- let offset_calc = calculate_offset ( * first, * increment, offset, false ) ;
796
794
let doc = & util:: replace_suffix ( & description, suffixes_str) ;
797
- w_impl_items. extend ( quote ! {
798
- #[ doc = #doc]
799
- #inline
800
- pub unsafe fn #name_sc( & mut self , n: usize ) -> #name_pc_w {
801
- #name_pc_w { w: self , offset: #offset_calc }
802
- }
803
- } ) ;
795
+ if !config. const_generic {
796
+ let offset_calc = calculate_offset ( * first, * increment, offset, false ) ;
797
+ w_impl_items. extend ( quote ! {
798
+ #[ doc = #doc]
799
+ #inline
800
+ pub unsafe fn #name_sc( & mut self , n: usize ) -> #name_pc_w {
801
+ #name_pc_w { w: self , offset: #offset_calc }
802
+ }
803
+ } ) ;
804
+ } else {
805
+ w_impl_items. extend ( quote ! {
806
+ #[ doc = #doc]
807
+ #inline
808
+ pub unsafe fn #name_sc<const O : usize >( & mut self ) -> #name_pc_w<O > {
809
+ #name_pc_w { w: self }
810
+ }
811
+ } ) ;
812
+ }
804
813
for ( i, suffix) in ( 0 ..* dim) . zip ( suffixes. iter ( ) ) {
805
814
let sub_offset = offset + ( i as u64 ) * ( * increment as u64 ) ;
806
815
let name_sc_n = Ident :: new (
@@ -824,8 +833,8 @@ pub fn fields(
824
833
w_impl_items. extend ( quote ! {
825
834
#[ doc = #doc]
826
835
#inline
827
- pub fn #name_sc_n( & mut self ) -> #name_pc_cgw <#sub_offset> {
828
- #name_pc_cgw { w: self }
836
+ pub fn #name_sc_n( & mut self ) -> #name_pc_w <#sub_offset> {
837
+ #name_pc_w { w: self }
829
838
}
830
839
} ) ;
831
840
}
0 commit comments