refix calculate offset
@@ -1007,18 +1007,15 @@ fn calculate_offset(
}
if offset != 0 {
let offset = &util::unsuffixed(offset);
- if with_parentheses {
- res = quote! { (#res + #offset) };
- } else {
res = quote! { #res + #offset };
}
+ let single_ident = (first == 0) && (increment == 1) && (offset == 0);
+ if with_parentheses && !single_ident {
+ quote! { (#res) }
} else {
- if with_parentheses {
- res = quote! { (#res) };
- }
- }
res
}
+}
fn description_with_bits(description: &str, offset: u64, width: u32) -> String {
let mut res = if width == 1 {
