]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/transmute-from-fn-item-types-lint.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![deny(transmute_from_fn_item_types)]
15 unsafe fn foo() -> (isize, *const (), Option
<fn()>) {
16 let i
= mem
::transmute(bar
);
17 //~^ ERROR is now zero-sized and has to be cast to a pointer before transmuting
18 //~^^ ERROR was previously accepted
20 let p
= mem
::transmute(foo
);
21 //~^ ERROR is now zero-sized and has to be cast to a pointer before transmuting
22 //~^^ ERROR was previously accepted
24 let of
= mem
::transmute(main
);
25 //~^ ERROR is now zero-sized and has to be cast to a pointer before transmuting
26 //~^^ ERROR was previously accepted
32 mem
::transmute
::<_
, *mut ()>(foo
);
33 //~^ ERROR is now zero-sized and has to be cast to a pointer before transmuting
34 //~^^ ERROR was previously accepted
36 mem
::transmute
::<_
, fn()>(bar
);
37 //~^ ERROR is now zero-sized and has to be cast to a pointer before transmuting
38 //~^^ ERROR was previously accepted
40 // No error if a coercion would otherwise occur.
41 mem
::transmute
::<fn(), usize>(main
);