Skip to content

Commit 72c24e2

Browse files
committed
rustc: remove unnecessary unsafe blocks/methods
1 parent 5244512 commit 72c24e2

File tree

6 files changed

+153
-175
lines changed

6 files changed

+153
-175
lines changed

src/librustc/back/link.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
615615
}
616616
617617
pub fn truncated_hash_result(symbol_hasher: &hash::State) -> ~str {
618-
unsafe {
619-
symbol_hasher.result_str()
620-
}
618+
symbol_hasher.result_str()
621619
}
622620
623621

src/librustc/middle/lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ pub impl<'self> LanguageItemCollector<'self> {
369369
}
370370

371371
fn collect_local_language_items(&self) {
372-
let this = unsafe { ptr::addr_of(&self) };
372+
let this = ptr::addr_of(&self);
373373
visit_crate(*self.crate, (), mk_simple_visitor(@SimpleVisitor {
374374
visit_item: |item| {
375375
for item.attrs.each |attribute| {

src/librustc/middle/resolve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use metadata::csearch::get_type_name_if_impl;
1919
use metadata::cstore::find_extern_mod_stmt_cnum;
2020
use metadata::decoder::{def_like, dl_def, dl_field, dl_impl};
2121
use middle::lang_items::LanguageItems;
22-
use middle::lint::{deny, allow, forbid, level, unused_imports, warn};
22+
use middle::lint::{allow, level, unused_imports};
2323
use middle::lint::{get_lint_level, get_lint_settings_level};
2424
use middle::pat_util::pat_bindings;
2525

src/librustc/middle/trans/base.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,8 @@ pub struct icx_popper {
9191
#[unsafe_destructor]
9292
impl Drop for icx_popper {
9393
fn finalize(&self) {
94-
unsafe {
95-
if self.ccx.sess.count_llvm_insns() {
96-
self.ccx.stats.llvm_insn_ctxt.pop();
97-
}
94+
if self.ccx.sess.count_llvm_insns() {
95+
self.ccx.stats.llvm_insn_ctxt.pop();
9896
}
9997
}
10098
}
@@ -145,9 +143,7 @@ pub fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv,
145143
llvm::LLVMGetOrInsertFunction(llmod, buf, llty)
146144
}
147145
});
148-
unsafe {
149-
lib::llvm::SetFunctionCallConv(llfn, cc);
150-
}
146+
lib::llvm::SetFunctionCallConv(llfn, cc);
151147
return llfn;
152148
}
153149

@@ -730,11 +726,9 @@ pub fn cast_shift_expr_rhs(cx: block, op: ast::binop,
730726

731727
pub fn cast_shift_const_rhs(op: ast::binop,
732728
lhs: ValueRef, rhs: ValueRef) -> ValueRef {
733-
unsafe {
734-
cast_shift_rhs(op, lhs, rhs,
735-
|a, b| unsafe { llvm::LLVMConstTrunc(a, b) },
736-
|a, b| unsafe { llvm::LLVMConstZExt(a, b) })
737-
}
729+
cast_shift_rhs(op, lhs, rhs,
730+
|a, b| unsafe { llvm::LLVMConstTrunc(a, b) },
731+
|a, b| unsafe { llvm::LLVMConstZExt(a, b) })
738732
}
739733

740734
pub fn cast_shift_rhs(op: ast::binop,
@@ -2865,9 +2859,7 @@ pub fn create_module_map(ccx: @CrateContext) -> ValueRef {
28652859
llvm::LLVMAddGlobal(ccx.llmod, maptype, buf)
28662860
}
28672861
});
2868-
unsafe {
2869-
lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage);
2870-
}
2862+
lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage);
28712863
let mut elts: ~[ValueRef] = ~[];
28722864
for ccx.module_data.each |key, &val| {
28732865
let elt = C_struct(~[p2i(ccx, C_cstr(ccx, @/*bad*/ copy *key)),

src/librustc/middle/trans/build.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ use core::str;
2727
use core::vec;
2828

2929
pub fn terminate(cx: block, _: &str) {
30-
unsafe {
31-
cx.terminated = true;
32-
}
30+
cx.terminated = true;
3331
}
3432

3533
pub fn check_not_terminated(cx: block) {

0 commit comments

Comments
 (0)