]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/auxiliary/linkage-visibility.rs
Update const_forget.rs
[rust.git] / src / test / ui-fulldeps / auxiliary / linkage-visibility.rs
1 // ignore-musl - dlsym doesn't see symbols without "-C link-arg=-Wl,--export-dynamic"
2
3 #![feature(rustc_private)]
4
5 // We're testing linkage visibility; the compiler warns us, but we want to
6 // do the runtime check that these functions aren't exported.
7 #![allow(private_no_mangle_fns)]
8
9 extern crate rustc_metadata;
10
11 use rustc_metadata::dynamic_lib::DynamicLibrary;
12
13 #[no_mangle]
14 pub fn foo() { bar(); }
15
16 pub fn foo2<T>() {
17     fn bar2() {
18         bar();
19     }
20     bar2();
21 }
22
23 #[no_mangle]
24 fn bar() { }
25
26 #[allow(dead_code)]
27 #[no_mangle]
28 fn baz() { }
29
30 pub fn test() {
31     let lib = DynamicLibrary::open(None).unwrap();
32     unsafe {
33         assert!(lib.symbol::<isize>("foo").is_ok());
34         assert!(lib.symbol::<isize>("baz").is_ok());
35         assert!(lib.symbol::<isize>("bar").is_ok());
36     }
37 }