Skip to content

Use backticks for the unsafe keyword in error messages #6027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub fn get_lint_dict() -> LintDict {
(~"unused_unsafe",
LintSpec {
lint: unused_unsafe,
desc: "unnecessary use of an \"unsafe\" block",
desc: "unnecessary use of an `unsafe` block",
default: warn
}),

Expand Down Expand Up @@ -949,7 +949,7 @@ fn check_item_unused_unsafe(cx: ty::ctxt, it: @ast::item) {
if !cx.used_unsafe.contains(&blk.node.id) {
cx.sess.span_lint(unused_unsafe, blk.node.id, it.id,
blk.span,
~"unnecessary \"unsafe\" block");
~"unnecessary `unsafe` block");
}
}
_ => ()
Expand Down
8 changes: 4 additions & 4 deletions src/test/compile-fail/unused-unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use core::libc;

fn callback<T>(_f: &fn() -> T) -> T { fail!() }

fn bad1() { unsafe {} } //~ ERROR: unnecessary "unsafe" block
fn bad2() { unsafe { bad1() } } //~ ERROR: unnecessary "unsafe" block
unsafe fn bad4() { unsafe {} } //~ ERROR: unnecessary "unsafe" block
fn bad5() { unsafe { do callback {} } } //~ ERROR: unnecessary "unsafe" block
fn bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
fn bad2() { unsafe { bad1() } } //~ ERROR: unnecessary `unsafe` block
unsafe fn bad4() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
fn bad5() { unsafe { do callback {} } } //~ ERROR: unnecessary `unsafe` block

unsafe fn good0() { libc::exit(1) }
fn good1() { unsafe { libc::exit(1) } }
Expand Down