]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/safety-ok.rs
Rollup merge of #82179 - mbartlett21:patch-5, r=joshtriplett
[rust.git] / src / test / ui / traits / safety-ok.rs
1 // run-pass
2 // Simple smoke test that unsafe traits can be compiled etc.
3
4
5 unsafe trait Foo {
6     fn foo(&self) -> isize;
7 }
8
9 unsafe impl Foo for isize {
10     fn foo(&self) -> isize { *self }
11 }
12
13 fn take_foo<F:Foo>(f: &F) -> isize { f.foo() }
14
15 fn main() {
16     let x: isize = 22;
17     assert_eq!(22, take_foo(&x));
18 }