@@ -305,7 +305,7 @@ impl Region {
305
305
let mut idents: Vec < _ > = self
306
306
. rbfs
307
307
. iter ( )
308
- . filter_map ( |f| f. syn_field . ident . as_ref ( ) . map ( |ident| ident . to_string ( ) ) )
308
+ . filter_map ( |f| f. syn_field . ident . as_ref ( ) . map ( ToString :: to_string) )
309
309
. collect ( ) ;
310
310
if idents. is_empty ( ) {
311
311
return None ;
@@ -343,7 +343,7 @@ impl Region {
343
343
let idents: Vec < _ > = self
344
344
. rbfs
345
345
. iter ( )
346
- . filter_map ( |f| f. syn_field . ident . as_ref ( ) . map ( |ident| ident . to_string ( ) ) )
346
+ . filter_map ( |f| f. syn_field . ident . as_ref ( ) . map ( ToString :: to_string) )
347
347
. collect ( ) ;
348
348
349
349
if idents. is_empty ( ) {
@@ -726,7 +726,7 @@ fn check_erc_derive_infos(
726
726
} ;
727
727
match register {
728
728
Register :: Single ( _) => {
729
- let ty_name = info_name. to_string ( ) ;
729
+ let ty_name = info_name. clone ( ) ;
730
730
* derive_info = match explicit_rpath {
731
731
None => {
732
732
match compare_this_against_prev (
@@ -758,7 +758,7 @@ fn check_erc_derive_infos(
758
758
let re = Regex :: new ( format ! ( "^{re_string}$" ) . as_str ( ) ) . map_err ( |_| {
759
759
anyhow ! ( "Error creating regex for register {}" , register. name)
760
760
} ) ?;
761
- let ty_name = info_name. to_string ( ) ; // keep suffix for regex matching
761
+ let ty_name = info_name. clone ( ) ; // keep suffix for regex matching
762
762
* derive_info = match explicit_rpath {
763
763
None => {
764
764
match compare_this_against_prev (
@@ -787,7 +787,7 @@ fn check_erc_derive_infos(
787
787
}
788
788
RegisterCluster :: Cluster ( cluster) => {
789
789
* derive_info = DeriveInfo :: Cluster ;
790
- ercs_type_info. push ( ( cluster. name . to_string ( ) , None , erc, derive_info) ) ;
790
+ ercs_type_info. push ( ( cluster. name . clone ( ) , None , erc, derive_info) ) ;
791
791
}
792
792
} ;
793
793
}
@@ -998,7 +998,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
998
998
doc,
999
999
name,
1000
1000
ty,
1001
- offset : unsuffixed ( info. address_offset ) ,
1001
+ offset : info. address_offset ,
1002
1002
} )
1003
1003
. raw_if ( false ) ;
1004
1004
cluster_expanded. push ( RegisterBlockField {
@@ -1052,14 +1052,19 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
1052
1052
& description,
1053
1053
) ;
1054
1054
let mut accessors = Vec :: with_capacity ( ( array_info. dim + 1 ) as _ ) ;
1055
+ let first_name = svd:: array:: names ( info, array_info) . next ( ) . unwrap ( ) ;
1056
+ let note = ( array_info. indexes ( ) . next ( ) . unwrap ( ) != "0" ) . then ( ||
1057
+ format ! ( "<div class=\" warning\" >`n` is the index of {0} in the array. `n == 0` corresponds to `{first_name}` {0}.</div>" , "cluster" )
1058
+ ) ;
1055
1059
accessors. push (
1056
1060
Accessor :: Array ( ArrayAccessor {
1057
1061
doc,
1058
1062
name : accessor_name. clone ( ) ,
1059
1063
ty : ty. clone ( ) ,
1060
- offset : unsuffixed ( info. address_offset ) ,
1061
- dim : unsuffixed ( array_info. dim ) ,
1062
- increment : unsuffixed ( array_info. dim_increment ) ,
1064
+ offset : info. address_offset ,
1065
+ dim : array_info. dim ,
1066
+ increment : array_info. dim_increment ,
1067
+ note,
1063
1068
} )
1064
1069
. raw_if ( !array_convertible) ,
1065
1070
) ;
@@ -1071,7 +1076,6 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
1071
1076
ci. address_offset ,
1072
1077
ci. description . as_deref ( ) . unwrap_or ( & ci. name ) ,
1073
1078
) ;
1074
- let i = unsuffixed ( i as u64 ) ;
1075
1079
accessors. push (
1076
1080
Accessor :: ArrayElem ( ArrayElemAccessor {
1077
1081
doc,
@@ -1114,7 +1118,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
1114
1118
doc,
1115
1119
name,
1116
1120
ty : ty. clone ( ) ,
1117
- offset : unsuffixed ( info. address_offset ) ,
1121
+ offset : info. address_offset ,
1118
1122
} )
1119
1123
. raw_if ( false ) ;
1120
1124
cluster_expanded. push ( RegisterBlockField {
@@ -1166,7 +1170,7 @@ fn expand_register(
1166
1170
doc,
1167
1171
name,
1168
1172
ty,
1169
- offset : unsuffixed ( info. address_offset ) ,
1173
+ offset : info. address_offset ,
1170
1174
} )
1171
1175
. raw_if ( false ) ;
1172
1176
register_expanded. push ( RegisterBlockField {
@@ -1235,14 +1239,19 @@ fn expand_register(
1235
1239
& description,
1236
1240
) ;
1237
1241
let mut accessors = Vec :: with_capacity ( ( array_info. dim + 1 ) as _ ) ;
1242
+ let first_name = svd:: array:: names ( info, array_info) . next ( ) . unwrap ( ) ;
1243
+ let note = ( array_info. indexes ( ) . next ( ) . unwrap ( ) != "0" ) . then ( ||
1244
+ format ! ( "<div class=\" warning\" >`n` is the index of {0} in the array. `n == 0` corresponds to `{first_name}` {0}.</div>" , "register" )
1245
+ ) ;
1238
1246
accessors. push (
1239
1247
Accessor :: Array ( ArrayAccessor {
1240
1248
doc,
1241
1249
name : accessor_name. clone ( ) ,
1242
1250
ty : ty. clone ( ) ,
1243
- offset : unsuffixed ( info. address_offset ) ,
1244
- dim : unsuffixed ( array_info. dim ) ,
1245
- increment : unsuffixed ( array_info. dim_increment ) ,
1251
+ offset : info. address_offset ,
1252
+ dim : array_info. dim ,
1253
+ increment : array_info. dim_increment ,
1254
+ note,
1246
1255
} )
1247
1256
. raw_if ( !array_convertible) ,
1248
1257
) ;
@@ -1259,7 +1268,6 @@ fn expand_register(
1259
1268
ri. address_offset ,
1260
1269
ri. description . as_deref ( ) . unwrap_or ( & ri. name ) ,
1261
1270
) ;
1262
- let i = unsuffixed ( i as u64 ) ;
1263
1271
accessors. push (
1264
1272
Accessor :: ArrayElem ( ArrayElemAccessor {
1265
1273
doc,
@@ -1302,7 +1310,7 @@ fn expand_register(
1302
1310
doc,
1303
1311
name,
1304
1312
ty : ty. clone ( ) ,
1305
- offset : unsuffixed ( info. address_offset ) ,
1313
+ offset : info. address_offset ,
1306
1314
} )
1307
1315
. raw_if ( false ) ;
1308
1316
register_expanded. push ( RegisterBlockField {
0 commit comments