]> git.lizzy.rs Git - rust.git/blob - tests/ui/traits/safety-trait-impl.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.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() { }