diff options
Diffstat (limited to 'tests/ui/traits/safety-ok-cc.rs')
-rw-r--r-- | tests/ui/traits/safety-ok-cc.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/traits/safety-ok-cc.rs b/tests/ui/traits/safety-ok-cc.rs new file mode 100644 index 000000000..099ba80e5 --- /dev/null +++ b/tests/ui/traits/safety-ok-cc.rs @@ -0,0 +1,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)); +} |