]> git.proxmox.com Git - rustc.git/blob - src/test/ui/extern/no-mangle-associated-fn.rs
New upstream version 1.58.1+dfsg1
[rustc.git] / src / test / ui / extern / no-mangle-associated-fn.rs
1 // aux-build: no-mangle-associated-fn.rs
2 // run-pass
3
4 extern crate no_mangle_associated_fn;
5
6 struct Foo;
7
8 impl Foo {
9 #[no_mangle]
10 fn foo() -> u8 {
11 1
12 }
13 }
14
15 trait Bar {
16 fn qux() -> u8;
17 }
18
19 impl Bar for Foo {
20 #[no_mangle]
21 fn qux() -> u8 {
22 4
23 }
24 }
25
26 fn main() {
27 extern "Rust" {
28 fn foo() -> u8;
29 fn bar() -> u8;
30 fn baz() -> u8;
31 fn qux() -> u8;
32 }
33 assert_eq!(unsafe { foo() }, 1);
34 assert_eq!(unsafe { bar() }, 2);
35 assert_eq!(unsafe { baz() }, 3);
36 assert_eq!(unsafe { qux() }, 4);
37 }