]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/safety-ok-cc.rs
Rollup merge of #99742 - sigaloid:master, r=thomcc
[rust.git] / src / test / ui / traits / safety-ok-cc.rs
1 // run-pass
2 // aux-build:trait_safety_lib.rs
3
4 // Simple smoke test that unsafe traits can be compiled across crates.
5
6
7 extern crate trait_safety_lib as lib;
8
9 use lib::Foo;
10
11 struct Bar { x: isize }
12 unsafe impl Foo for Bar {
13     fn foo(&self) -> isize { self.x }
14 }
15
16 fn take_foo<F:Foo>(f: &F) -> isize { f.foo() }
17
18 fn main() {
19     let x: isize = 22;
20     assert_eq!(22, take_foo(&x));
21
22     let x: Bar = Bar { x: 23 };
23     assert_eq!(23, take_foo(&x));
24 }