Skip to content

Commit f0afe23

Browse files
committed
auto merge of #5978 : alexcrichton/rust/issue-5954, r=catamorphism
Closes #5954
2 parents ae3b869 + 3c2a44b commit f0afe23

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

src/librustc/middle/lint.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub fn get_lint_dict() -> LintDict {
260260
(~"unused_unsafe",
261261
LintSpec {
262262
lint: unused_unsafe,
263-
desc: "unnecessary use of an \"unsafe\" block or function",
263+
desc: "unnecessary use of an \"unsafe\" block",
264264
default: warn
265265
}),
266266

@@ -958,17 +958,6 @@ fn check_fn(tcx: ty::ctxt, fk: &visit::fn_kind, decl: &ast::fn_decl,
958958
_body: &ast::blk, span: span, id: ast::node_id) {
959959
debug!("lint check_fn fk=%? id=%?", fk, id);
960960

961-
// Check for an 'unsafe fn' which doesn't need to be unsafe
962-
match *fk {
963-
visit::fk_item_fn(_, _, ast::unsafe_fn, _) => {
964-
if !tcx.used_unsafe.contains(&id) {
965-
tcx.sess.span_lint(unused_unsafe, id, id, span,
966-
~"unnecessary \"unsafe\" function");
967-
}
968-
}
969-
_ => ()
970-
}
971-
972961
// Check for deprecated modes
973962
match *fk {
974963
// don't complain about blocks, since they tend to get their modes

src/test/compile-fail/unused-unsafe.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ fn callback<T>(_f: &fn() -> T) -> T { fail!() }
1818

1919
fn bad1() { unsafe {} } //~ ERROR: unnecessary "unsafe" block
2020
fn bad2() { unsafe { bad1() } } //~ ERROR: unnecessary "unsafe" block
21-
unsafe fn bad3() {} //~ ERROR: unnecessary "unsafe" function
22-
unsafe fn bad4() { unsafe {} } //~ ERROR: unnecessary "unsafe" function
23-
//~^ ERROR: unnecessary "unsafe" block
21+
unsafe fn bad4() { unsafe {} } //~ ERROR: unnecessary "unsafe" block
2422
fn bad5() { unsafe { do callback {} } } //~ ERROR: unnecessary "unsafe" block
2523

2624
unsafe fn good0() { libc::exit(1) }
@@ -38,7 +36,6 @@ fn good2() {
3836
}
3937
}
4038

41-
#[allow(unused_unsafe)] unsafe fn allowed0() {}
42-
#[allow(unused_unsafe)] fn allowed1() { unsafe {} }
39+
#[allow(unused_unsafe)] fn allowed() { unsafe {} }
4340

4441
fn main() { }

0 commit comments

Comments
 (0)