@@ -9,8 +9,8 @@ use quote::{quote, ToTokens};
9
9
use syn:: { punctuated:: Punctuated , Token } ;
10
10
11
11
use 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 ,
14
14
} ;
15
15
use anyhow:: { anyhow, bail, Context , Result } ;
16
16
@@ -655,7 +655,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
655
655
} else {
656
656
util:: replace_suffix ( & cluster. name , "" )
657
657
} ;
658
- let ty = syn :: Type :: Path ( name_to_ty ( & ty_name) ) ;
658
+ let ty = name_to_ty ( & ty_name) ;
659
659
660
660
match cluster {
661
661
Cluster :: Single ( info) => {
@@ -776,7 +776,7 @@ fn expand_register(register: &Register, config: &Config) -> Result<Vec<RegisterB
776
776
} else {
777
777
util:: replace_suffix ( & info_name, "" )
778
778
} ;
779
- let ty = name_to_wrapped_ty ( & ty_name) ;
779
+ let ty = name_to_ty ( & ty_name) ;
780
780
781
781
match register {
782
782
Register :: Single ( info) => {
@@ -928,55 +928,47 @@ fn cluster_block(
928
928
let name_snake_case = mod_name. to_snake_case_ident ( span) ;
929
929
let name_constant_case = mod_name. to_constant_case_ident ( span) ;
930
930
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 {
934
932
let dparent = util:: parent ( & dpath) ;
935
933
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 ( ) )
939
935
} else {
940
936
util:: block_path_to_ty ( & dparent, span)
941
937
} ;
942
938
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) ) ) ;
947
939
derived
948
940
. path
949
941
. segments
950
942
. push ( path_segment ( dname. to_constant_case_ident ( span) ) ) ;
951
943
952
- quote ! {
944
+ Ok ( quote ! {
953
945
#[ doc = #description]
954
946
pub use #derived as #name_constant_case;
955
- }
947
+ } )
956
948
} else {
957
949
let cpath = path. new_cluster ( & c. name ) ;
958
950
let mod_items = render_ercs ( & mut c. children , & cpath, index, config) ?;
959
951
960
952
// Generate the register block.
961
953
let reg_block = register_or_cluster_block ( & c. children , Some ( & mod_name) , config) ?;
962
954
963
- quote ! {
955
+ let mod_items = quote ! {
964
956
#reg_block
965
957
966
958
#mod_items
967
- }
968
- } ;
959
+ } ;
969
960
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 ;
973
964
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
+ }
980
972
}
981
973
982
974
fn new_syn_field ( ident : Ident , ty : syn:: Type ) -> syn:: Field {
0 commit comments