]> git.lizzy.rs Git - rust.git/blob - src/test/auxiliary/linkage-visibility.rs
rollup merge of #24541: alexcrichton/issue-24538
[rust.git] / src / test / auxiliary / linkage-visibility.rs
1 // Copyright 2013 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.
4 //
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.
10
11 #![feature(std_misc)]
12
13 use std::dynamic_lib::DynamicLibrary;
14
15 #[no_mangle]
16 pub fn foo() { bar(); }
17
18 pub fn foo2<T>() {
19     fn bar2() {
20         bar();
21     }
22     bar2();
23 }
24
25 #[no_mangle]
26 fn bar() { }
27
28 #[no_mangle]
29 fn baz() { }
30
31 pub fn test() {
32     let lib = DynamicLibrary::open(None).unwrap();
33     unsafe {
34         assert!(lib.symbol::<isize>("foo").is_ok());
35         assert!(lib.symbol::<isize>("baz").is_err());
36         assert!(lib.symbol::<isize>("bar").is_err());
37     }
38 }