@@ -9,8 +9,8 @@ use quote::{quote, ToTokens};
99use syn:: { punctuated:: Punctuated , Token } ;
1010
1111use crate :: util:: {
12- self , array_proxy_type, name_to_ty, name_to_wrapped_ty , new_syn_u32, path_segment, type_path,
13- unsuffixed , Config , FullName , ToSanitizedCase , BITS_PER_BYTE ,
12+ self , array_proxy_type, name_to_ty, new_syn_u32, path_segment, type_path, unsuffixed , Config ,
13+ FullName , ToSanitizedCase , BITS_PER_BYTE ,
1414} ;
1515use anyhow:: { anyhow, bail, Context , Result } ;
1616
@@ -655,7 +655,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
655655 } else {
656656 util:: replace_suffix ( & cluster. name , "" )
657657 } ;
658- let ty = syn :: Type :: Path ( name_to_ty ( & ty_name) ) ;
658+ let ty = name_to_ty ( & ty_name) ;
659659
660660 match cluster {
661661 Cluster :: Single ( info) => {
@@ -776,7 +776,7 @@ fn expand_register(register: &Register, config: &Config) -> Result<Vec<RegisterB
776776 } else {
777777 util:: replace_suffix ( & info_name, "" )
778778 } ;
779- let ty = name_to_wrapped_ty ( & ty_name) ;
779+ let ty = name_to_ty ( & ty_name) ;
780780
781781 match register {
782782 Register :: Single ( info) => {
@@ -928,55 +928,47 @@ fn cluster_block(
928928 let name_snake_case = mod_name. to_snake_case_ident ( span) ;
929929 let name_constant_case = mod_name. to_constant_case_ident ( span) ;
930930
931- let struct_path = name_to_ty ( & mod_name) ;
932-
933- let mod_items = if let Some ( dpath) = dpath {
931+ if let Some ( dpath) = dpath {
934932 let dparent = util:: parent ( & dpath) ;
935933 let mut derived = if & dparent == path {
936- let mut segments = Punctuated :: new ( ) ;
937- segments. push ( path_segment ( Ident :: new ( "super" , span) ) ) ;
938- type_path ( segments)
934+ type_path ( Punctuated :: new ( ) )
939935 } else {
940936 util:: block_path_to_ty ( & dparent, span)
941937 } ;
942938 let dname = util:: replace_suffix ( & index. clusters . get ( & dpath) . unwrap ( ) . name , "" ) ;
943- derived
944- . path
945- . segments
946- . push ( path_segment ( dname. to_snake_case_ident ( span) ) ) ;
947939 derived
948940 . path
949941 . segments
950942 . push ( path_segment ( dname. to_constant_case_ident ( span) ) ) ;
951943
952- quote ! {
944+ Ok ( quote ! {
953945 #[ doc = #description]
954946 pub use #derived as #name_constant_case;
955- }
947+ } )
956948 } else {
957949 let cpath = path. new_cluster ( & c. name ) ;
958950 let mod_items = render_ercs ( & mut c. children , & cpath, index, config) ?;
959951
960952 // Generate the register block.
961953 let reg_block = register_or_cluster_block ( & c. children , Some ( & mod_name) , config) ?;
962954
963- quote ! {
955+ let mod_items = quote ! {
964956 #reg_block
965957
966958 #mod_items
967- }
968- } ;
959+ } ;
969960
970- Ok ( quote ! {
971- #[ doc = #description]
972- pub use #struct_path ;
961+ Ok ( quote ! {
962+ #[ doc = #description]
963+ pub use #name_snake_case :: #name_constant_case ;
973964
974- ///Cluster
975- #[ doc = #description]
976- pub mod #name_snake_case {
977- #mod_items
978- }
979- } )
965+ ///Cluster
966+ #[ doc = #description]
967+ pub mod #name_snake_case {
968+ #mod_items
969+ }
970+ } )
971+ }
980972}
981973
982974fn new_syn_field ( ident : Ident , ty : syn:: Type ) -> syn:: Field {
0 commit comments