1 // FIXME: This file is tracking old lint behavior that's still unchanged in the
2 // unstable -Zthir-unsafeck implementation. See lint-unused-unsafe.rs for more details.
4 // Exercise the unused_unsafe attribute in some positive and negative cases
6 // compile-flags: -Zthir-unsafeck
9 #![deny(unused_unsafe)]
18 fn callback<T, F>(_f: F) -> T where F: FnOnce() -> T { panic!() }
21 fn bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
22 fn bad2() { unsafe { bad1() } } //~ ERROR: unnecessary `unsafe` block
23 unsafe fn bad3() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
24 fn bad4() { unsafe { callback(||{}) } } //~ ERROR: unnecessary `unsafe` block
25 unsafe fn bad5() { unsafe { unsf() } } //~ ERROR: unnecessary `unsafe` block
27 unsafe { // don't put the warning here
28 unsafe { //~ ERROR: unnecessary `unsafe` block
34 unsafe { //~ ERROR: unnecessary `unsafe` block
35 unsafe { //~ ERROR: unnecessary `unsafe` block
41 unsafe fn good0() { unsf() }
42 fn good1() { unsafe { unsf() } }
44 /* bug uncovered when implementing warning about unused unsafe blocks. Be
45 sure that when purity is inherited that the source of the unsafe-ness
46 is tracked correctly */
48 unsafe fn what() -> Vec<String> { panic!() }
56 unsafe fn good3() { foo::bar() }
57 fn good4() { unsafe { foo::bar() } }
59 #[allow(unused_unsafe)] fn allowed() { unsafe {} }