@@ -305,7 +305,7 @@ impl Region {
305305 let mut idents: Vec<_> = self
306306 .rbfs
307307 .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))
309309 .collect();
310310 if idents.is_empty() {
311311 return None;
@@ -343,7 +343,7 @@ impl Region {
343343 let idents: Vec<_> = self
344344 .rbfs
345345 .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))
347347 .collect();
348348
349349 if idents.is_empty() {
@@ -726,7 +726,7 @@ fn check_erc_derive_infos(
726726 };
727727 match register {
728728 Register::Single(_) => {
729- let ty_name = info_name.to_string ();
729+ let ty_name = info_name.clone ();
730730 *derive_info = match explicit_rpath {
731731 None => {
732732 match compare_this_against_prev(
@@ -758,7 +758,7 @@ fn check_erc_derive_infos(
758758 let re = Regex::new(format!("^{re_string}$").as_str()).map_err(|_| {
759759 anyhow!("Error creating regex for register {}", register.name)
760760 })?;
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
762762 *derive_info = match explicit_rpath {
763763 None => {
764764 match compare_this_against_prev(
@@ -787,7 +787,7 @@ fn check_erc_derive_infos(
787787 }
788788 RegisterCluster::Cluster(cluster) => {
789789 *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));
791791 }
792792 };
793793 }
@@ -998,7 +998,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
998998 doc,
999999 name,
10001000 ty,
1001- offset: unsuffixed( info.address_offset) ,
1001+ offset: info.address_offset,
10021002 })
10031003 .raw_if(false);
10041004 cluster_expanded.push(RegisterBlockField {
@@ -1052,14 +1052,19 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
10521052 &description,
10531053 );
10541054 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+ );
10551059 accessors.push(
10561060 Accessor::Array(ArrayAccessor {
10571061 doc,
10581062 name: accessor_name.clone(),
10591063 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,
10631068 })
10641069 .raw_if(!array_convertible),
10651070 );
@@ -1071,7 +1076,6 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
10711076 ci.address_offset,
10721077 ci.description.as_deref().unwrap_or(&ci.name),
10731078 );
1074- let i = unsuffixed(i as u64);
10751079 accessors.push(
10761080 Accessor::ArrayElem(ArrayElemAccessor {
10771081 doc,
@@ -1114,7 +1118,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
11141118 doc,
11151119 name,
11161120 ty: ty.clone(),
1117- offset: unsuffixed( info.address_offset) ,
1121+ offset: info.address_offset,
11181122 })
11191123 .raw_if(false);
11201124 cluster_expanded.push(RegisterBlockField {
@@ -1166,7 +1170,7 @@ fn expand_register(
11661170 doc,
11671171 name,
11681172 ty,
1169- offset: unsuffixed( info.address_offset) ,
1173+ offset: info.address_offset,
11701174 })
11711175 .raw_if(false);
11721176 register_expanded.push(RegisterBlockField {
@@ -1235,14 +1239,19 @@ fn expand_register(
12351239 &description,
12361240 );
12371241 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+ );
12381246 accessors.push(
12391247 Accessor::Array(ArrayAccessor {
12401248 doc,
12411249 name: accessor_name.clone(),
12421250 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,
12461255 })
12471256 .raw_if(!array_convertible),
12481257 );
@@ -1259,7 +1268,6 @@ fn expand_register(
12591268 ri.address_offset,
12601269 ri.description.as_deref().unwrap_or(&ri.name),
12611270 );
1262- let i = unsuffixed(i as u64);
12631271 accessors.push(
12641272 Accessor::ArrayElem(ArrayElemAccessor {
12651273 doc,
@@ -1302,7 +1310,7 @@ fn expand_register(
13021310 doc,
13031311 name,
13041312 ty: ty.clone(),
1305- offset: unsuffixed( info.address_offset) ,
1313+ offset: info.address_offset,
13061314 })
13071315 .raw_if(false);
13081316 register_expanded.push(RegisterBlockField {
0 commit comments