Skip to content

Commit

Permalink
ureg: Add transmute type annotations
Browse files Browse the repository at this point in the history
Newer version of rust warn about this.

Signed-off-by: Arthur Heymans <[email protected]>
  • Loading branch information
ArthurHeymans committed Dec 18, 2024
1 parent 19658a6 commit 73cc174
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions hw/latest/registers/src/axi_dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<AxiDmaFsmE, ()> {
if val < 4 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, AxiDmaFsmE>(val) })
} else {
Err(())
}
Expand Down Expand Up @@ -1828,7 +1828,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<RdRouteE, ()> {
if val < 4 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, RdRouteE>(val) })
} else {
Err(())
}
Expand Down Expand Up @@ -1870,7 +1870,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<WrRouteE, ()> {
if val < 4 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, WrRouteE>(val) })
} else {
Err(())
}
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/doe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<DoeCmdE, ()> {
if val < 4 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, DoeCmdE>(val) })
} else {
Err(())
}
Expand Down
4 changes: 2 additions & 2 deletions hw/latest/registers/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<Ctrl, ()> {
if val < 4 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, Ctrl>(val) })
} else {
Err(())
}
Expand Down Expand Up @@ -1357,7 +1357,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<KvErrorE, ()> {
if val < 0x100 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, KvErrorE>(val) })
} else {
Err(())
}
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<KvErrorE, ()> {
if val < 0x100 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, KvErrorE>(val) })
} else {
Err(())
}
Expand Down
4 changes: 2 additions & 2 deletions hw/latest/registers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<KvErrorE, ()> {
if val < 0x100 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, KvErrorE>(val) })
} else {
Err(())
}
Expand Down Expand Up @@ -808,7 +808,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<PvErrorE, ()> {
if val < 0x100 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, PvErrorE>(val) })
} else {
Err(())
}
Expand Down
4 changes: 2 additions & 2 deletions hw/latest/registers/src/mbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<MboxFsmE, ()> {
if val < 8 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, MboxFsmE>(val) })
} else {
Err(())
}
Expand Down Expand Up @@ -581,7 +581,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<MboxStatusE, ()> {
if val < 0x10 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, MboxStatusE>(val) })
} else {
Err(())
}
Expand Down
4 changes: 2 additions & 2 deletions hw/latest/registers/src/mldsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<Ctrl, ()> {
if val < 8 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, Ctrl>(val) })
} else {
Err(())
}
Expand Down Expand Up @@ -1240,7 +1240,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<KvErrorE, ()> {
if val < 0x100 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, KvErrorE>(val) })
} else {
Err(())
}
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/sha512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<KvErrorE, ()> {
if val < 0x100 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, KvErrorE>(val) })
} else {
Err(())
}
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/sha512_acc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<ShaCmdE, ()> {
if val < 4 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, ShaCmdE>(val) })
} else {
Err(())
}
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/soc_ifc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4652,7 +4652,7 @@ pub mod enums {
#[inline(always)]
fn try_from(val: u32) -> Result<DeviceLifecycleE, ()> {
if val < 4 {
Ok(unsafe { core::mem::transmute(val) })
Ok(unsafe { core::mem::transmute::<u32, DeviceLifecycleE>(val) })
} else {
Err(())
}
Expand Down
2 changes: 1 addition & 1 deletion ureg/lib/codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn generate_enum(e: &Enum) -> TokenStream {
// This transmute is safe because the check above ensures
// that the value has a corresponding enum variant, and the
// enum is using repr(u32).
Ok(unsafe { core::mem::transmute(val) } )
Ok(unsafe { core::mem::transmute::<u32, #enum_name>(val) } )
} else {
Err(())
}
Expand Down

0 comments on commit 73cc174

Please sign in to comment.