diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-08-30 12:54:50 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-08-31 16:21:47 -0700 |
| commit | 4128cc4cb44acb415be3cfdfa008fd6c95ceee74 (patch) | |
| tree | 321c8c7ed1c28247377bf4122365c047d69f891f /src/rustc | |
| parent | 638db28c472c1edadc3c37f900df28f14cca7665 (diff) | |
| download | rust-4128cc4cb44acb415be3cfdfa008fd6c95ceee74.tar.gz rust-4128cc4cb44acb415be3cfdfa008fd6c95ceee74.zip | |
Make utility funs in core::int, core::uint, etc. not by-reference
Closes #3302
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/back/rpath.rs | 14 | ||||
| -rw-r--r-- | src/rustc/driver/rustc.rs | 4 | ||||
| -rw-r--r-- | src/rustc/middle/resolve.rs | 2 | ||||
| -rw-r--r-- | src/rustc/middle/trans/foreign.rs | 49 | ||||
| -rw-r--r-- | src/rustc/middle/ty.rs | 4 |
5 files changed, 36 insertions, 37 deletions
diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index 286ca505714..032eb6342e1 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -125,20 +125,20 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path { let split2 = abs2.components; let len1 = vec::len(split1); let len2 = vec::len(split2); - assert len1 > 0u; - assert len2 > 0u; + assert len1 > 0; + assert len2 > 0; - let max_common_path = uint::min(&len1, &len2) - 1u; - let mut start_idx = 0u; + let max_common_path = uint::min(len1, len2) - 1; + let mut start_idx = 0; while start_idx < max_common_path && split1[start_idx] == split2[start_idx] { - start_idx += 1u; + start_idx += 1; } let mut path = ~[]; - for uint::range(start_idx, len1 - 1u) |_i| { vec::push(path, ~".."); }; + for uint::range(start_idx, len1 - 1) |_i| { vec::push(path, ~".."); }; - vec::push_all(path, vec::view(split2, start_idx, len2 - 1u)); + vec::push_all(path, vec::view(split2, start_idx, len2 - 1)); if vec::is_not_empty(path) { return Path("").push_many(path); diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 2289a51e7c4..f55688bd234 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -81,8 +81,8 @@ Options: fn describe_warnings() { let lint_dict = lint::get_lint_dict(); - let mut max_key = 0u; - for lint_dict.each_key |k| { max_key = uint::max(&k.len(), &max_key); } + let mut max_key = 0; + for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); } fn padded(max: uint, s: ~str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 923118d0a26..c2f7bd2ae29 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -304,7 +304,7 @@ fn Atom(n: uint) -> Atom { /// Creates a hash table of atoms. fn atom_hashmap<V:copy>() -> hashmap<Atom,V> { - hashmap::<Atom,V>(uint::hash, uint::eq) + hashmap::<Atom,V>(|x| { uint::hash(*x) }, |x, y| { uint::eq(*x, *y) }) } /// One local scope. diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index 05f1d83cc89..8291fbe91af 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -5,11 +5,10 @@ import driver::session::{session, arch_x86_64}; import syntax::codemap::span; import libc::c_uint; import syntax::{attr, ast_map}; -import lib::llvm::{ llvm, TypeRef, ValueRef, - ModuleRef, CallConv, Attribute, - StructRetAttribute, ByValAttribute, - SequentiallyConsistent, Acquire, Release, - Xchg }; +import lib::llvm::{ llvm, TypeRef, ValueRef, Integer, Pointer, Float, Double, + Struct, Array, ModuleRef, CallConv, Attribute, + StructRetAttribute, ByValAttribute, + SequentiallyConsistent, Acquire, Release, Xchg }; import syntax::{ast, ast_util}; import back::{link, abi}; import common::*; @@ -79,19 +78,19 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn ty_align(ty: TypeRef) -> uint { - return match llvm::LLVMGetTypeKind(ty) as int { - 8 /* integer */ => { - ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u + return match llvm::LLVMGetTypeKind(ty) { + Integer => { + ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7) / 8 } - 12 /* pointer */ => 8u, - 2 /* float */ => 4u, - 3 /* double */ => 8u, - 10 /* struct */ => { - do vec::foldl(0u, struct_tys(ty)) |a, t| { - uint::max(&a, &ty_align(t)) + Pointer => 8, + Float => 4, + Double => 8, + Struct => { + do vec::foldl(0, struct_tys(ty)) |a, t| { + uint::max(a, ty_align(t)) } } - 11 /* array */ => { + Array => { let elt = llvm::LLVMGetElementType(ty); ty_align(elt) } @@ -100,19 +99,19 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn ty_size(ty: TypeRef) -> uint { - return match llvm::LLVMGetTypeKind(ty) as int { - 8 /* integer */ => { - ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u + return match llvm::LLVMGetTypeKind(ty) { + Integer => { + ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7) / 8 } - 12 /* pointer */ => 8u, - 2 /* float */ => 4u, - 3 /* double */ => 8u, - 10 /* struct */ => { - do vec::foldl(0u, struct_tys(ty)) |s, t| { + Pointer => 8, + Float => 4, + Double => 8, + Struct => { + do vec::foldl(0, struct_tys(ty)) |s, t| { s + ty_size(t) } } - 11 /* array */ => { + Array => { let len = llvm::LLVMGetArrayLength(ty) as uint; let elt = llvm::LLVMGetElementType(ty); let eltsz = ty_size(elt); @@ -123,7 +122,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn all_mem(cls: ~[mut x86_64_reg_class]) { - for uint::range(0u, cls.len()) |i| { + for uint::range(0, cls.len()) |i| { cls[i] = memory_class; } } diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index e15c9547e07..287a7582a99 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -1912,9 +1912,9 @@ fn type_size(cx: ctxt, ty: t) -> uint { let variants = substd_enum_variants(cx, did, substs); variants.foldl( // find max size of any variant 0, - |m, v| uint::max(&m, + |m, v| uint::max(m, // find size of this variant: - &v.args.foldl(0, |s, a| s + type_size(cx, a)))) + v.args.foldl(0, |s, a| s + type_size(cx, a)))) } ty_param(_) | ty_self => { |
