rust/src/test/ui/unsafe/unsafe-trait-impl.rs
2018-12-25 21:08:33 -07:00

15 lines
325 B
Rust

// Check that safe fns are not a subtype of unsafe fns.
trait Foo {
unsafe fn len(&self) -> u32;
}
impl Foo for u32 {
fn len(&self) -> u32 { *self }
//~^ ERROR method `len` has an incompatible type for trait
//~| expected type `unsafe fn(&u32) -> u32`
//~| found type `fn(&u32) -> u32`
}
fn main() { }