Skip to content

Commit 229a882

Browse files
AatchJames Miller
authored and
James Miller
committed
librust: cleanup warnings (except 1)
1 parent 4e3b196 commit 229a882

File tree

7 files changed

+30
-42
lines changed

7 files changed

+30
-42
lines changed

src/librustc/lib/llvm.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2192,9 +2192,7 @@ pub fn type_to_str_inner(names: @TypeNames, outer0: &[TypeRef], ty: TypeRef)
21922192
let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
21932193
let n_args = llvm::LLVMCountParamTypes(ty) as uint;
21942194
let args = vec::from_elem(n_args, 0 as TypeRef);
2195-
unsafe {
2196-
llvm::LLVMGetParamTypes(ty, vec::raw::to_ptr(args));
2197-
}
2195+
llvm::LLVMGetParamTypes(ty, vec::raw::to_ptr(args));
21982196
// See [Note at-str]
21992197
return fmt!("fn(%s) -> %s",
22002198
tys_str(names, outer, args),

src/librustc/metadata/loader.rs

+21-23
Original file line numberDiff line numberDiff line change
@@ -204,35 +204,33 @@ fn get_metadata_section(os: os,
204204
let si = mk_section_iter(of.llof);
205205
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
206206
let name_buf = llvm::LLVMGetSectionName(si.llsi);
207-
let name = unsafe { str::raw::from_c_str(name_buf) };
207+
let name = str::raw::from_c_str(name_buf);
208208
debug!("get_metadata_section: name %s", name);
209209
if name == read_meta_section_name(os) {
210210
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
211211
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
212212
let mut found = None;
213-
unsafe {
214-
let cvbuf: *u8 = cast::transmute(cbuf);
215-
let vlen = encoder::metadata_encoding_version.len();
216-
debug!("checking %u bytes of metadata-version stamp",
217-
vlen);
218-
let minsz = uint::min(vlen, csz);
219-
let mut version_ok = false;
220-
do vec::raw::buf_as_slice(cvbuf, minsz) |buf0| {
221-
version_ok = (buf0 ==
222-
encoder::metadata_encoding_version);
223-
}
224-
if !version_ok { return None; }
213+
let cvbuf: *u8 = cast::transmute(cbuf);
214+
let vlen = encoder::metadata_encoding_version.len();
215+
debug!("checking %u bytes of metadata-version stamp",
216+
vlen);
217+
let minsz = uint::min(vlen, csz);
218+
let mut version_ok = false;
219+
do vec::raw::buf_as_slice(cvbuf, minsz) |buf0| {
220+
version_ok = (buf0 ==
221+
encoder::metadata_encoding_version);
222+
}
223+
if !version_ok { return None; }
225224

226-
let cvbuf1 = ptr::offset(cvbuf, vlen);
227-
debug!("inflating %u bytes of compressed metadata",
228-
csz - vlen);
229-
do vec::raw::buf_as_slice(cvbuf1, csz-vlen) |bytes| {
230-
let inflated = flate::inflate_bytes(bytes);
231-
found = Some(@(inflated));
232-
}
233-
if found != None {
234-
return found;
235-
}
225+
let cvbuf1 = ptr::offset(cvbuf, vlen);
226+
debug!("inflating %u bytes of compressed metadata",
227+
csz - vlen);
228+
do vec::raw::buf_as_slice(cvbuf1, csz-vlen) |bytes| {
229+
let inflated = flate::inflate_bytes(bytes);
230+
found = Some(@(inflated));
231+
}
232+
if found != None {
233+
return found;
236234
}
237235
}
238236
llvm::LLVMMoveToNextSection(si.llsi);

src/librustc/middle/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3050,7 +3050,7 @@ pub fn write_metadata(cx: &mut CrateContext, crate: &ast::crate) {
30503050
30513051
// Writes the current ABI version into the crate.
30523052
pub fn write_abi_version(ccx: &mut CrateContext) {
3053-
mk_global(ccx, ~"rust_abi_version", C_uint(ccx, abi::abi_version),
3053+
mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version),
30543054
false);
30553055
}
30563056

src/librustc/middle/trans/build.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -618,13 +618,11 @@ pub fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) ->
618618
ValueRef {
619619
unsafe {
620620
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
621-
unsafe {
622-
count_insn(cx, "inboundsgep");
621+
count_insn(cx, "inboundsgep");
623622
return llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
624623
vec::raw::to_ptr(Indices),
625624
Indices.len() as c_uint,
626625
noname());
627-
}
628626
}
629627
}
630628

@@ -1072,11 +1070,9 @@ pub fn Trap(cx: block) {
10721070
});
10731071
assert!((T as int != 0));
10741072
let Args: ~[ValueRef] = ~[];
1075-
unsafe {
1076-
count_insn(cx, "trap");
1077-
llvm::LLVMBuildCall(b, T, vec::raw::to_ptr(Args),
1078-
Args.len() as c_uint, noname());
1079-
}
1073+
count_insn(cx, "trap");
1074+
llvm::LLVMBuildCall(b, T, vec::raw::to_ptr(Args),
1075+
Args.len() as c_uint, noname());
10801076
}
10811077
}
10821078

src/librustc/middle/trans/context.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ impl CrateContext {
211211
int_type: int_type,
212212
float_type: float_type,
213213
opaque_vec_type: T_opaque_vec(targ_cfg),
214-
builder: BuilderRef_res(unsafe {
215-
llvm::LLVMCreateBuilderInContext(llcx)
216-
}),
214+
builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)),
217215
shape_cx: mk_ctxt(llmod),
218216
crate_map: crate_map,
219217
uses_gc: false,

src/librustc/middle/trans/debuginfo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ fn create_basic_type(cx: @mut CrateContext, t: ty::t, _span: span) -> DIType {
242242
ast::ty_f32 => (~"f32", DW_ATE_float),
243243
ast::ty_f64 => (~"f64", DW_ATE_float)
244244
},
245-
_ => cx.sess.bug(~"debuginfo::create_basic_type - t is invalid type")
245+
_ => cx.sess.bug("debuginfo::create_basic_type - t is invalid type")
246246
};
247247

248248
let (size, align) = size_and_align_of(cx, t);
@@ -572,7 +572,7 @@ fn create_ty(cx: @mut CrateContext, t: ty::t, span: span) -> DIType {
572572
ty::ty_tup(ref elements) => {
573573
create_tuple(cx, t, *elements, span)
574574
},
575-
_ => cx.sess.bug(~"debuginfo: unexpected type in create_ty")
575+
_ => cx.sess.bug("debuginfo: unexpected type in create_ty")
576576
};
577577

578578
dbg_cx(cx).created_types.insert(ty_id, ty_md);

src/librustc/middle/typeck/check/vtable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use core::prelude::*;
1212

13-
use middle::resolve::Impl;
1413
use middle::ty::param_ty;
1514
use middle::ty;
1615
use middle::typeck::check::{FnCtxt, impl_self_ty};
@@ -27,7 +26,6 @@ use util::ppaux;
2726

2827
use core::hashmap::HashSet;
2928
use core::result;
30-
use core::uint;
3129
use syntax::ast;
3230
use syntax::ast_util;
3331
use syntax::codemap::span;

0 commit comments

Comments
 (0)