Skip to content

Commit

Permalink
Coerce to a function pointer before transmuting.
Browse files Browse the repository at this point in the history
This fixes the warning appearing from rust-lang/rust#31710.
  • Loading branch information
SSheldon committed Mar 20, 2016
1 parent 88f3a29 commit ad1eb08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ unsafe fn try_no_ret<F>(closure: F) -> Result<(), *mut Exception>
closure();
}

let f: extern fn(&mut Option<F>) = try_objc_execute_closure;
let f: extern fn(*mut c_void) = mem::transmute(f);
// Wrap the closure in an Option so it can be taken
let mut closure = Some(closure);
let f = mem::transmute(try_objc_execute_closure::<F>);
let context = &mut closure as *mut _ as *mut c_void;

let mut exception = ptr::null_mut();
Expand Down

0 comments on commit ad1eb08

Please sign in to comment.