rust/tests/ui/unsafe/unsafe-trait-impl.rs
2023-01-11 09:32:08 +00:00

15 lines
331 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 signature `unsafe fn(&u32) -> _`
//~| found signature `fn(&u32) -> _`
}
fn main() { }