Skip to content

Commit 0b0c756

Browse files
author
James Miller
committed
Fix warnings in trans
1 parent 81cf72c commit 0b0c756

16 files changed

+166
-227
lines changed

src/librustc/lib/llvm.rs

-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ use core::prelude::*;
1313
use core::hashmap::HashMap;
1414
use core::libc::{c_uint, c_ushort};
1515
use core::option;
16-
use core::ptr;
1716
use core::str;
18-
use core::vec;
1917

2018
use middle::trans::type_::Type;
2119

src/librustc/middle/trans/base.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use back::{link, abi};
3030
use driver::session;
3131
use driver::session::Session;
3232
use lib::llvm::{ContextRef, ModuleRef, ValueRef, BasicBlockRef};
33-
use lib::llvm::{llvm, True, False};
33+
use lib::llvm::{llvm, True};
3434
use lib;
3535
use metadata::common::LinkMeta;
3636
use metadata::{csearch, cstore, encoder};
@@ -1462,7 +1462,7 @@ pub fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) {
14621462
// allocation for large data structures, and the generated code will be
14631463
// awful. (A telltale sign of this is large quantities of
14641464
// `mov [byte ptr foo],0` in the generated code.)
1465-
pub fn memzero(cx: block, llptr: ValueRef, llty: TypeRef) {
1465+
pub fn memzero(cx: block, llptr: ValueRef, ty: Type) {
14661466
let _icx = cx.insn_ctxt("memzero");
14671467
let ccx = cx.ccx();
14681468

@@ -1493,7 +1493,7 @@ pub fn alloca(cx: block, ty: Type) -> ValueRef {
14931493
alloca_maybe_zeroed(cx, ty, false)
14941494
}
14951495

1496-
pub fn alloca_maybe_zeroed(cx: block, t: TypeRef, zero: bool) -> ValueRef {
1496+
pub fn alloca_maybe_zeroed(cx: block, ty: Type, zero: bool) -> ValueRef {
14971497
let _icx = cx.insn_ctxt("alloca");
14981498
if cx.unreachable {
14991499
unsafe {
@@ -1506,7 +1506,7 @@ pub fn alloca_maybe_zeroed(cx: block, t: TypeRef, zero: bool) -> ValueRef {
15061506
p
15071507
}
15081508

1509-
pub fn arrayalloca(cx: block, t: TypeRef, v: ValueRef) -> ValueRef {
1509+
pub fn arrayalloca(cx: block, ty: Type, v: ValueRef) -> ValueRef {
15101510
let _icx = cx.insn_ctxt("arrayalloca");
15111511
if cx.unreachable {
15121512
unsafe {
@@ -2885,8 +2885,7 @@ pub fn write_metadata(cx: &mut CrateContext, crate: &ast::crate) {
28852885

28862886
// Writes the current ABI version into the crate.
28872887
pub fn write_abi_version(ccx: &mut CrateContext) {
2888-
mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version),
2889-
false);
2888+
mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version), false);
28902889
}
28912890

28922891
pub fn trans_crate(sess: session::Session,

src/librustc/middle/trans/build.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use syntax::codemap::span;
2222
use middle::trans::type_::Type;
2323

2424
use core::cast;
25-
use core::hashmap::HashMap;
2625
use core::libc::{c_uint, c_ulonglong, c_char};
26+
use core::hashmap::HashMap;
2727
use core::str;
2828
use core::vec;
2929

@@ -619,15 +619,12 @@ pub fn GEPi(cx: block, base: ValueRef, ixs: &[uint]) -> ValueRef {
619619
return InBoundsGEP(cx, base, v);
620620
}
621621

622-
pub fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) ->
623-
ValueRef {
622+
pub fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
624623
unsafe {
625624
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
626625
count_insn(cx, "inboundsgep");
627-
return llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
628-
vec::raw::to_ptr(Indices),
629-
Indices.len() as c_uint,
630-
noname());
626+
return llvm::LLVMBuildInBoundsGEP(
627+
B(cx), Pointer, vec::raw::to_ptr(Indices), Indices.len() as c_uint, noname());
631628
}
632629
}
633630

@@ -1077,8 +1074,7 @@ pub fn Trap(cx: block) {
10771074
assert!((T as int != 0));
10781075
let Args: ~[ValueRef] = ~[];
10791076
count_insn(cx, "trap");
1080-
llvm::LLVMBuildCall(b, T, vec::raw::to_ptr(Args),
1081-
Args.len() as c_uint, noname());
1077+
llvm::LLVMBuildCall(b, T, vec::raw::to_ptr(Args), Args.len() as c_uint, noname());
10821078
}
10831079
}
10841080

@@ -1088,8 +1084,8 @@ pub fn LandingPad(cx: block, Ty: Type, PersFn: ValueRef,
10881084
check_not_terminated(cx);
10891085
assert!(!cx.unreachable);
10901086
count_insn(cx, "landingpad");
1091-
return llvm::LLVMBuildLandingPad(B(cx), Ty.to_ref(), PersFn,
1092-
NumClauses as c_uint, noname());
1087+
return llvm::LLVMBuildLandingPad(
1088+
B(cx), Ty.to_ref(), PersFn, NumClauses as c_uint, noname());
10931089
}
10941090
}
10951091

src/librustc/middle/trans/cabi_arm.rs

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

1111
use lib::llvm::{llvm, Integer, Pointer, Float, Double, Struct, Array};
1212
use lib::llvm::{Attribute, StructRetAttribute};
13-
use lib::llvm::True;
1413
use middle::trans::cabi::{ABIInfo, FnType, LLVMType};
1514

1615
use middle::trans::type_::Type;
@@ -116,14 +115,12 @@ fn classify_arg_ty(ty: Type) -> (LLVMType, Option<Attribute>) {
116115
}
117116

118117
fn is_reg_ty(ty: Type) -> bool {
119-
unsafe {
120-
match ty.kind() {
121-
Integer
122-
| Pointer
123-
| Float
124-
| Double => true,
125-
_ => false
126-
}
118+
match ty.kind() {
119+
Integer
120+
| Pointer
121+
| Float
122+
| Double => true,
123+
_ => false
127124
}
128125
}
129126

src/librustc/middle/trans/cabi_mips.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@
1111
use core::prelude::*;
1212

1313
use core::libc::c_uint;
14-
use core::ptr;
1514
use core::uint;
1615
use core::vec;
1716
use lib::llvm::{llvm, Integer, Pointer, Float, Double, Struct, Array};
1817
use lib::llvm::{Attribute, StructRetAttribute};
19-
use lib::llvm::True;
2018
use middle::trans::context::task_llcx;
21-
use middle::trans::common::*;
2219
use middle::trans::cabi::*;
2320

2421
use middle::trans::type_::Type;
@@ -122,15 +119,13 @@ fn classify_arg_ty(ty: Type, offset: &mut uint) -> (LLVMType, Option<Attribute>)
122119
}
123120

124121
fn is_reg_ty(ty: Type) -> bool {
125-
unsafe {
126-
return match ty.kind() {
127-
Integer
128-
| Pointer
129-
| Float
130-
| Double => true,
131-
_ => false
132-
};
133-
}
122+
return match ty.kind() {
123+
Integer
124+
| Pointer
125+
| Float
126+
| Double => true,
127+
_ => false
128+
};
134129
}
135130

136131
fn padding_ty(align: uint, offset: uint) -> Option<Type> {

src/librustc/middle/trans/cabi_x86.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use core::prelude::*;
1212

1313
use driver::session::{os_win32, os_macos};
1414
use lib::llvm::*;
15-
use lib::llvm::llvm::*;
1615
use super::cabi::*;
1716
use super::common::*;
1817
use super::machine::*;
@@ -43,7 +42,7 @@ impl ABIInfo for X86_ABIInfo {
4342
// http://www.angelcode.com/dev/callconv/callconv.html
4443
// Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
4544
let sret = {
46-
let returning_a_struct = unsafe { rty.kind() == Struct && ret_def };
45+
let returning_a_struct = rty.kind() == Struct && ret_def;
4746
let big_struct = match self.ccx.sess.targ_cfg.os {
4847
os_win32 | os_macos => llsize_of_alloc(self.ccx, rty) > 8,
4948
_ => true

0 commit comments

Comments
 (0)