]> git.proxmox.com Git - rustc.git/blob - tests/ui/traits/safety-trait-impl.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / traits / safety-trait-impl.rs
1 // Check that unsafe traits require unsafe impls and that inherent
2 // impls cannot be unsafe.
3
4 trait SafeTrait {
5 fn foo(&self) { }
6 }
7
8 unsafe trait UnsafeTrait {
9 fn foo(&self) { }
10 }
11
12 unsafe impl UnsafeTrait for u8 { } // OK
13
14 impl UnsafeTrait for u16 { } //~ ERROR requires an `unsafe impl` declaration
15
16 unsafe impl SafeTrait for u32 { } //~ ERROR the trait `SafeTrait` is not unsafe
17
18 fn main() { }