So thanks to @eddyb we recently landed a fix for https://github.com/rust-lang/rust/issues/19925. However, one effect of this was that support for a somewhat common pattern of using transmute to get a fn pointer is now slated to be removed. In particular, code that transmutes from a fn item into a fn pointer, like the following, now gets a “forward compat warning”:
extern "C" fn foo(userdata: Box<i32>) {
...
}
let f: extern "C" fn(*mut i32) = transmute(foo);
callback(f);
Please see my write-up in https://github.com/rust-lang/rust/issues/19925 for details. Unfortunately, there is no mega-simple work-around. You can refactor things to not require the transmute, or you can add a cast, like so:
let f: extern "C" fn(*mut i32) = transmute(foo as extern "C" fn(_))
let f: extern "C" fn(*mut i32) = transmute(foo as usize) /* works too, if yucky */
However, another possibility is that we could simply remove the warnings, and continue to allow transmute from a fn item to a reified fn pointer to reify the fn pointer. It is an odd special-case, but doesn’t pose any particular problem.
I’m not entirely clear on how big the impact of this change is, but I wanted to raise the point for discussion.
cc @eddyb
cc @pcwalton