Skip to content

Commit 010f3c4

Browse files
committed
Fix overflow for width==32
1 parent 64c833f commit 010f3c4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ pub fn gen_register_r(r: &Register, d: &Defaults) -> Vec<Tokens> {
227227
}
228228
} else {
229229
let width_ty = width.to_ty();
230-
let mask: u32 = (1 << width) - 1;
231-
let mask = Lit::Int(u64::from(mask), IntTy::Unsuffixed);
230+
let mask: u64 = (1 << width) - 1;
231+
let mask = Lit::Int(mask, IntTy::Unsuffixed);
232232

233233
quote! {
234234
pub fn #name(&self) -> #width_ty {
@@ -314,8 +314,8 @@ pub fn gen_register_w(r: &Register, d: &Defaults) -> Vec<Tokens> {
314314
}
315315
} else {
316316
let width_ty = width.to_ty();
317-
let mask: u32 = (1 << width) - 1;
318-
let mask = Lit::Int(u64::from(mask), IntTy::Unsuffixed);
317+
let mask = (1 << width) - 1;
318+
let mask = Lit::Int(mask, IntTy::Unsuffixed);
319319

320320
quote! {
321321
pub fn #name(&mut self, value: #width_ty) -> &mut Self {

0 commit comments

Comments
 (0)