about summary refs log tree commit diff
path: root/tests/ui/traits/safety-ok-cc.rs
blob: fe65ea9d2d7c1b041941780dafd54bdcc3767169 (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));
}