1 // Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![allow(unused_unsafe)]
21 fn allowed() { unsafe {} }
22 unsafe fn also_allowed() {}
23 unsafe trait AllowedUnsafe { }
24 unsafe impl AllowedUnsafe for super::Bar {}
27 macro_rules! unsafe_in_macro {
29 unsafe {} //~ ERROR: usage of an `unsafe` block
33 unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function
34 unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait
35 unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait
38 unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method
39 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
40 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
44 unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method
45 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
51 unsafe fn allowed_unsafe(&self);
52 unsafe fn allowed_unsafe_provided(&self) {}
57 unsafe fn baz(&self) {}
58 unsafe fn provided_override(&self) {}
63 unsafe fn baz(&self) {}
64 unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
75 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
80 unsafe fn baz(&self) {}
81 unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
85 unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method
90 unsafe fn unsafe_provided(&self) {}
96 unsafe {} //~ ERROR: usage of an `unsafe` block