Skip to content

Commit

Permalink
Merge pull request #1528 from sdroege/unnecessary-casts-via-usize
Browse files Browse the repository at this point in the history
Remove unnecessary casts of function pointers through usize
  • Loading branch information
sdroege committed Nov 29, 2023
2 parents 22c3351 + 46bd074 commit a2f936b
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/codegen/function_body_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,25 +542,14 @@ impl Builder {
is_mut: false,
value: Box::new(Chunk::Custom(
if is_destroy || trampoline.scope.is_async() {
format!("Box_::from_raw({func} as *mut _)")
format!("Box_::from_raw({} as *mut {})", func, trampoline.bound_name)
} else if trampoline.scope.is_call() {
format!(
"{} as *const _ as usize as *mut {}",
func, trampoline.bound_name
)
format!("{} as *mut {}", func, trampoline.bound_name)
} else {
format!("&*({func} as *mut _)")
format!("&*({} as *mut {})", func, trampoline.bound_name)
},
)),
type_: Some(Box::new(Chunk::Custom(
if is_destroy || trampoline.scope.is_async() {
format!("Box_<{}>", trampoline.bound_name)
} else if trampoline.scope.is_call() {
format!("*mut {}", trampoline.bound_name)
} else {
format!("&{}", trampoline.bound_name)
},
))),
type_: None,
});
if !is_destroy && *trampoline.nullable {
if trampoline.scope.is_async() {
Expand Down Expand Up @@ -1016,7 +1005,7 @@ impl Builder {
Chunk::FfiCallParameter {
transformation_type: TransformationType::ToGlibDirect {
name: if all_call {
format!("super_callback{pos} as *const _ as usize as *mut _")
format!("super_callback{pos} as *const _ as *mut _")
} else {
format!("Box_::into_raw(super_callback{pos}) as *mut _")
},
Expand Down

0 comments on commit a2f936b

Please sign in to comment.