summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/safety-ok-cc.rs
blob: 099ba80e5b51f7617a708ab8d11d3a38ac7336dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// run-pass
// aux-build:trait_safety_lib.rs

// Simple smoke test that unsafe traits can be compiled across crates.


extern crate trait_safety_lib as lib;

use lib::Foo;

struct Bar { x: isize }
unsafe impl Foo for Bar {
    fn foo(&self) -> isize { self.x }
}

fn take_foo<F:Foo>(f: &F) -> isize { f.foo() }

fn main() {
    let x: isize = 22;
    assert_eq!(22, take_foo(&x));

    let x: Bar = Bar { x: 23 };
    assert_eq!(23, take_foo(&x));
}