2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2014-12-10 17:24:10 -05:00
|
|
|
// Simple smoke test that unsafe traits can be compiled etc.
|
|
|
|
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2014-12-10 17:24:10 -05:00
|
|
|
unsafe trait Foo {
|
2015-03-25 17:06:52 -07:00
|
|
|
fn foo(&self) -> isize;
|
2014-12-10 17:24:10 -05:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
unsafe impl Foo for isize {
|
|
|
|
fn foo(&self) -> isize { *self }
|
2014-12-10 17:24:10 -05:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn take_foo<F:Foo>(f: &F) -> isize { f.foo() }
|
2014-12-10 17:24:10 -05:00
|
|
|
|
|
|
|
fn main() {
|
2015-03-25 17:06:52 -07:00
|
|
|
let x: isize = 22;
|
2014-12-10 17:24:10 -05:00
|
|
|
assert_eq!(22, take_foo(&x));
|
|
|
|
}
|