Skip to content

Commit 46bd074

Browse files
committed
Remove unnecessary casts of function pointers through usize
1 parent 22c3351 commit 46bd074

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/codegen/function_body_chunk.rs

+5-16
Original file line numberDiff line numberDiff line change
@@ -542,25 +542,14 @@ impl Builder {
542542
is_mut: false,
543543
value: Box::new(Chunk::Custom(
544544
if is_destroy || trampoline.scope.is_async() {
545-
format!("Box_::from_raw({func} as *mut _)")
545+
format!("Box_::from_raw({} as *mut {})", func, trampoline.bound_name)
546546
} else if trampoline.scope.is_call() {
547-
format!(
548-
"{} as *const _ as usize as *mut {}",
549-
func, trampoline.bound_name
550-
)
547+
format!("{} as *mut {}", func, trampoline.bound_name)
551548
} else {
552-
format!("&*({func} as *mut _)")
549+
format!("&*({} as *mut {})", func, trampoline.bound_name)
553550
},
554551
)),
555-
type_: Some(Box::new(Chunk::Custom(
556-
if is_destroy || trampoline.scope.is_async() {
557-
format!("Box_<{}>", trampoline.bound_name)
558-
} else if trampoline.scope.is_call() {
559-
format!("*mut {}", trampoline.bound_name)
560-
} else {
561-
format!("&{}", trampoline.bound_name)
562-
},
563-
))),
552+
type_: None,
564553
});
565554
if !is_destroy && *trampoline.nullable {
566555
if trampoline.scope.is_async() {
@@ -1016,7 +1005,7 @@ impl Builder {
10161005
Chunk::FfiCallParameter {
10171006
transformation_type: TransformationType::ToGlibDirect {
10181007
name: if all_call {
1019-
format!("super_callback{pos} as *const _ as usize as *mut _")
1008+
format!("super_callback{pos} as *const _ as *mut _")
10201009
} else {
10211010
format!("Box_::into_raw(super_callback{pos}) as *mut _")
10221011
},

0 commit comments

Comments
 (0)