@@ -606,7 +606,6 @@ pub fn fields(
606606 if can_write {
607607 let new_pc_aw = Ident :: new ( & ( name_pc. clone ( ) + "_AW" ) , span) ;
608608 let name_pc_w = Ident :: new ( & ( name_pc. clone ( ) + "_W" ) , span) ;
609- let name_pc_cgw = Ident :: new ( & ( name_pc. clone ( ) + "_CGW" ) , span) ;
610609
611610 let mut proxy_items = TokenStream :: new ( ) ;
612611 let mut unsafety = unsafety ( f. write_constraint . as_ref ( ) , width) ;
@@ -752,27 +751,27 @@ pub fn fields(
752751 } ;
753752
754753 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+ }
767761
768- if config. const_generic {
762+ impl <' a> #name_pc_w<' a> {
763+ #proxy_items
764+ #proxy_items_fa
765+ }
766+ } ) ;
767+ } else {
769768 mod_items. extend ( quote ! {
770769 #[ doc = #cgdoc]
771- pub struct #name_pc_cgw <' a, const O : usize > {
770+ pub struct #name_pc_w <' a, const O : usize > {
772771 w: & ' a mut W ,
773772 }
774773
775- impl <' a, const O : usize > #name_pc_cgw <' a, O > {
774+ impl <' a, const O : usize > #name_pc_w <' a, O > {
776775 #proxy_items
777776 #proxy_items_cg
778777 }
@@ -792,15 +791,25 @@ pub fn fields(
792791 }
793792
794793 if let Some ( ( first, dim, increment, suffixes, suffixes_str) ) = & field_dim {
795- let offset_calc = calculate_offset ( * first, * increment, offset, false ) ;
796794 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+ }
804813 for ( i, suffix) in ( 0 ..* dim) . zip ( suffixes. iter ( ) ) {
805814 let sub_offset = offset + ( i as u64 ) * ( * increment as u64 ) ;
806815 let name_sc_n = Ident :: new (
@@ -824,8 +833,8 @@ pub fn fields(
824833 w_impl_items. extend ( quote ! {
825834 #[ doc = #doc]
826835 #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 }
829838 }
830839 } ) ;
831840 }
0 commit comments