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