From 4128cc4cb44acb415be3cfdfa008fd6c95ceee74 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 30 Aug 2012 12:54:50 -0700 Subject: [PATCH] Make utility funs in core::int, core::uint, etc. not by-reference Closes #3302 --- src/fuzzer/fuzzer.rs | 10 ++-- src/libcore/int-template.rs | 26 +++++----- src/libcore/int-template/int.rs | 6 +-- src/libcore/io.rs | 4 +- src/libcore/str.rs | 4 +- src/libcore/uint-template.rs | 26 +++++----- src/libcore/uint-template/uint.rs | 4 +- src/libcore/vec.rs | 4 +- src/libstd/arena.rs | 4 +- src/libstd/map.rs | 10 ++-- src/libstd/net_tcp.rs | 2 +- src/libstd/par.rs | 4 +- src/libstd/rope.rs | 2 +- src/libstd/sort.rs | 2 +- src/libsyntax/ast_util.rs | 4 +- src/libsyntax/parse/comments.rs | 2 +- src/rustc/back/rpath.rs | 14 +++--- src/rustc/driver/rustc.rs | 4 +- src/rustc/middle/resolve.rs | 2 +- src/rustc/middle/trans/foreign.rs | 49 +++++++++---------- src/rustc/middle/ty.rs | 4 +- src/rustdoc/unindent_pass.rs | 6 +-- .../borrowck-borrowed-uniq-rvalue.rs | 4 +- 23 files changed, 99 insertions(+), 98 deletions(-) diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 1423d0050df..dae1540daff 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -249,18 +249,18 @@ fn check_variants_T( cx: context ) { error!("%s contains %u %s objects", filename.to_str(), - vec::len(things), thing_label); + things.len(), thing_label); // Assuming we're not generating any token_trees let intr = syntax::parse::token::mk_fake_ident_interner(); - let L = vec::len(things); + let L = things.len(); - if L < 100u { - do under(uint::min(&L, &20u)) |i| { + if L < 100 { + do under(uint::min(L, 20)) |i| { log(error, ~"Replacing... #" + uint::str(i)); let fname = str::from_slice(filename.to_str()); - do under(uint::min(&L, &30u)) |j| { + do under(uint::min(L, 30)) |j| { log(error, ~"With... " + stringifier(@things[j], intr)); let crate2 = @replacer(crate, i, things[j], cx.mode); // It would be best to test the *crate* for stability, but diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index 6b572d12626..bc080ac0d63 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -25,21 +25,21 @@ const bytes : uint = (inst::bits / 8); const min_value: T = (-1 as T) << (bits - 1); const max_value: T = min_value - 1 as T; -pure fn min(x: &T, y: &T) -> T { if *x < *y { *x } else { *y } } -pure fn max(x: &T, y: &T) -> T { if *x > *y { *x } else { *y } } +pure fn min(x: T, y: T) -> T { if x < y { x } else { y } } +pure fn max(x: T, y: T) -> T { if x > y { x } else { y } } -pure fn add(x: &T, y: &T) -> T { *x + *y } -pure fn sub(x: &T, y: &T) -> T { *x - *y } -pure fn mul(x: &T, y: &T) -> T { *x * *y } -pure fn div(x: &T, y: &T) -> T { *x / *y } -pure fn rem(x: &T, y: &T) -> T { *x % *y } +pure fn add(x: T, y: T) -> T { x + y } +pure fn sub(x: T, y: T) -> T { x - y } +pure fn mul(x: T, y: T) -> T { x * y } +pure fn div(x: T, y: T) -> T { x / y } +pure fn rem(x: T, y: T) -> T { x % y } -pure fn lt(x: &T, y: &T) -> bool { *x < *y } -pure fn le(x: &T, y: &T) -> bool { *x <= *y } -pure fn eq(x: &T, y: &T) -> bool { *x == *y } -pure fn ne(x: &T, y: &T) -> bool { *x != *y } -pure fn ge(x: &T, y: &T) -> bool { *x >= *y } -pure fn gt(x: &T, y: &T) -> bool { *x > *y } +pure fn lt(x: T, y: T) -> bool { x < y } +pure fn le(x: T, y: T) -> bool { x <= y } +pure fn eq(x: T, y: T) -> bool { x == y } +pure fn ne(x: T, y: T) -> bool { x != y } +pure fn ge(x: T, y: T) -> bool { x >= y } +pure fn gt(x: T, y: T) -> bool { x > y } pure fn is_positive(x: T) -> bool { x > 0 as T } pure fn is_negative(x: T) -> bool { x < 0 as T } diff --git a/src/libcore/int-template/int.rs b/src/libcore/int-template/int.rs index 96ca59335a5..d990ba97afa 100644 --- a/src/libcore/int-template/int.rs +++ b/src/libcore/int-template/int.rs @@ -2,9 +2,9 @@ type T = int; const bits: uint = uint::bits; /// Produce a uint suitable for use in a hash table -pure fn hash(x: &int) -> uint { - let u : uint = *x as uint; - uint::hash(&u) +pure fn hash(x: int) -> uint { + let u : uint = x as uint; + uint::hash(u) } /// Returns `base` raised to the power of `exponent` diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 9ba942cb0b7..f351ee77caa 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -285,7 +285,7 @@ type ByteBuf = {buf: &[const u8], mut pos: uint}; impl ByteBuf: Reader { fn read(buf: &[mut u8], len: uint) -> uint { - let count = uint::min(&len, &(self.buf.len() - self.pos)); + let count = uint::min(len, self.buf.len() - self.pos); vec::u8::memcpy(buf, vec::const_view(self.buf, self.pos, self.buf.len()), @@ -668,7 +668,7 @@ impl MemBuffer: Writer { let v_len = v.len(); let buf_len = buf.len(); - let count = uint::max(&buf_len, &(self.pos + v_len)); + let count = uint::max(buf_len, self.pos + v_len); vec::reserve(buf, count); unsafe { vec::unsafe::set_len(buf, count); } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 888d992321c..d2c9a07319a 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -682,7 +682,7 @@ pure fn eq(a: &~str, b: &~str) -> bool { /// Bytewise slice less than pure fn lt(a: &str, b: &str) -> bool { let (a_len, b_len) = (a.len(), b.len()); - let mut end = uint::min(&a_len, &b_len); + let mut end = uint::min(a_len, b_len); let mut i = 0; while i < end { @@ -698,7 +698,7 @@ pure fn lt(a: &str, b: &str) -> bool { /// Bytewise less than or equal pure fn le(a: &str, b: &str) -> bool { let (a_len, b_len) = (a.len(), b.len()); - let mut end = uint::min(&a_len, &b_len); + let mut end = uint::min(a_len, b_len); let mut i = 0; while i < end { diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 5119a5dd562..dfab2e36096 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -24,21 +24,21 @@ const bytes : uint = (inst::bits / 8); const min_value: T = 0 as T; const max_value: T = 0 as T - 1 as T; -pure fn min(x: &T, y: &T) -> T { if *x < *y { *x } else { *y } } -pure fn max(x: &T, y: &T) -> T { if *x > *y { *x } else { *y } } +pure fn min(x: T, y: T) -> T { if x < y { x } else { y } } +pure fn max(x: T, y: T) -> T { if x > y { x } else { y } } -pure fn add(x: &T, y: &T) -> T { *x + *y } -pure fn sub(x: &T, y: &T) -> T { *x - *y } -pure fn mul(x: &T, y: &T) -> T { *x * *y } -pure fn div(x: &T, y: &T) -> T { *x / *y } -pure fn rem(x: &T, y: &T) -> T { *x % *y } +pure fn add(x: T, y: T) -> T { x + y } +pure fn sub(x: T, y: T) -> T { x - y } +pure fn mul(x: T, y: T) -> T { x * y } +pure fn div(x: T, y: T) -> T { x / y } +pure fn rem(x: T, y: T) -> T { x % y } -pure fn lt(x: &T, y: &T) -> bool { *x < *y } -pure fn le(x: &T, y: &T) -> bool { *x <= *y } -pure fn eq(x: &T, y: &T) -> bool { *x == *y } -pure fn ne(x: &T, y: &T) -> bool { *x != *y } -pure fn ge(x: &T, y: &T) -> bool { *x >= *y } -pure fn gt(x: &T, y: &T) -> bool { *x > *y } +pure fn lt(x: T, y: T) -> bool { x < y } +pure fn le(x: T, y: T) -> bool { x <= y } +pure fn eq(x: T, y: T) -> bool { x == y } +pure fn ne(x: T, y: T) -> bool { x != y } +pure fn ge(x: T, y: T) -> bool { x >= y } +pure fn gt(x: T, y: T) -> bool { x > y } pure fn is_positive(x: T) -> bool { x > 0 as T } pure fn is_negative(x: T) -> bool { x < 0 as T } diff --git a/src/libcore/uint-template/uint.rs b/src/libcore/uint-template/uint.rs index fc65d9a63e4..8954e5c4a67 100644 --- a/src/libcore/uint-template/uint.rs +++ b/src/libcore/uint-template/uint.rs @@ -61,8 +61,8 @@ pure fn div_round(x: uint, y: uint) -> uint { pure fn div_floor(x: uint, y: uint) -> uint { return x / y; } /// Produce a uint suitable for use in a hash table -pure fn hash(x: &uint) -> uint { - hash::hash_uint(*x) as uint +pure fn hash(x: uint) -> uint { + hash::hash_uint(x) as uint } /** diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 984092e9a58..2e93788e9ac 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1427,7 +1427,7 @@ impl @[T]: Eq { pure fn lt(a: &[T], b: &[T]) -> bool { let (a_len, b_len) = (a.len(), b.len()); - let mut end = uint::min(&a_len, &b_len); + let mut end = uint::min(a_len, b_len); let mut i = 0; while i < end { @@ -1841,7 +1841,7 @@ mod u8 { pure fn cmp(a: &~[u8], b: &~[u8]) -> int { let a_len = len(*a); let b_len = len(*b); - let n = uint::min(&a_len, &b_len) as libc::size_t; + let n = uint::min(a_len, b_len) as libc::size_t; let r = unsafe { libc::memcmp(unsafe::to_ptr(*a) as *libc::c_void, unsafe::to_ptr(*b) as *libc::c_void, n) as int diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 162e5f2c071..7609fa70454 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -135,7 +135,7 @@ impl &Arena { fn alloc_pod_grow(n_bytes: uint, align: uint) -> *u8 { // Allocate a new chunk. let chunk_size = at_vec::capacity(self.pod_head.data); - let new_min_chunk_size = uint::max(&n_bytes, &chunk_size); + let new_min_chunk_size = uint::max(n_bytes, chunk_size); self.chunks = @cons(copy self.pod_head, self.chunks); self.pod_head = chunk(uint::next_power_of_two(new_min_chunk_size + 1u), true); @@ -177,7 +177,7 @@ impl &Arena { fn alloc_nonpod_grow(n_bytes: uint, align: uint) -> (*u8, *u8) { // Allocate a new chunk. let chunk_size = at_vec::capacity(self.head.data); - let new_min_chunk_size = uint::max(&n_bytes, &chunk_size); + let new_min_chunk_size = uint::max(n_bytes, chunk_size); self.chunks = @cons(copy self.head, self.chunks); self.head = chunk(uint::next_power_of_two(new_min_chunk_size + 1u), false); diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 2a2e6b5efc6..f2dfb3200f3 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -426,12 +426,12 @@ fn bytes_hash() -> hashmap<~[u8], V> { /// Construct a hashmap for int keys fn int_hash() -> hashmap { - return hashmap(int::hash, int::eq); + return hashmap(|x| { int::hash(*x) }, |x, y| { int::eq(*x, *y)}); } /// Construct a hashmap for uint keys fn uint_hash() -> hashmap { - return hashmap(uint::hash, uint::eq); + return hashmap(|x| { uint::hash(*x) }, |x, y| { uint::eq(*x, *y) } ); } /// Convenience function for adding keys to a hashmap with nil type keys @@ -473,15 +473,15 @@ fn hash_from_bytes(items: &[(~[u8], V)]) -> hashmap<~[u8], V> { /// Construct a hashmap from a vector with int keys fn hash_from_ints(items: &[(int, V)]) -> hashmap { - hash_from_vec(int::hash, int::eq, items) + hash_from_vec(|x| { int::hash(*x) }, |x, y| { int::eq(*x, *y) }, items) } /// Construct a hashmap from a vector with uint keys fn hash_from_uints(items: &[(uint, V)]) -> hashmap { - hash_from_vec(uint::hash, uint::eq, items) + hash_from_vec(|x| { uint::hash(*x) }, |x, y| { uint::eq(*x, *y) } , items) } -// XXX Transitionary +// XXX Transitional impl Managed>: map { pure fn size() -> uint { diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index fa799ee3e31..255ce96e986 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -772,7 +772,7 @@ impl TcpSocketBuf: io::Reader { } } - let count = uint::min(&len, &self.data.buf.len()); + let count = uint::min(len, self.data.buf.len()); let mut data = ~[]; self.data.buf <-> data; diff --git a/src/libstd/par.rs b/src/libstd/par.rs index ab5062148e0..34ea2433bed 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -30,7 +30,7 @@ fn map_slices( ~[f()(0u, xs)] } else { - let num_tasks = uint::min(&max_tasks, &(len / min_granularity)); + let num_tasks = uint::min(max_tasks, len / min_granularity); let items_per_task = len / num_tasks; @@ -38,7 +38,7 @@ fn map_slices( let mut base = 0u; log(info, ~"spawning tasks"); while base < len { - let end = uint::min(&len, &(base + items_per_task)); + let end = uint::min(len, base + items_per_task); // FIXME: why is the :: annotation required here? (#2617) do vec::as_buf::(xs) |p, _len| { let f = f(); diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 12676377def..23f33a79c53 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -1004,7 +1004,7 @@ mod node { right : right, char_len: char_len(left) + char_len(right), byte_len: byte_len(left) + byte_len(right), - height: uint::max(&height(left), &height(right)) + 1u + height: uint::max(height(left), height(right)) + 1u }) } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 52d25f53940..33e6feb8427 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -242,7 +242,7 @@ mod test_qsort { let expected = ~[1, 2, 3]; - sort::quick_sort(int::le, names); + sort::quick_sort(|x, y| { int::le(*x, *y) }, names); let immut_names = vec::from_mut(names); diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 3badb0fbfce..f89b1607a70 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -568,8 +568,8 @@ fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range { let min = @mut int::max_value; let max = @mut int::min_value; do visit_ids_fn |id| { - *min = int::min(min, &id); - *max = int::max(max, &(id + 1)); + *min = int::min(*min, id); + *max = int::max(*max, id + 1); } return {min:*min, max:*max}; } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index b4c9eb6f69e..7b18ca532e0 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -182,7 +182,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[~str], s: ~str, col: uint) unsafe { let mut s1; let len = str::len(s); - if all_whitespace(s, 0u, uint::min(&len, &col)) { + if all_whitespace(s, 0u, uint::min(len, col)) { if col < len { s1 = str::slice(s, col, len); } else { s1 = ~""; } 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() -> hashmap { - hashmap::(uint::hash, uint::eq) + hashmap::(|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 => { diff --git a/src/rustdoc/unindent_pass.rs b/src/rustdoc/unindent_pass.rs index 644f298cf33..31d1584e760 100644 --- a/src/rustdoc/unindent_pass.rs +++ b/src/rustdoc/unindent_pass.rs @@ -45,18 +45,18 @@ fn unindent(s: ~str) -> ~str { min_indent } else { saw_first_line = true; - let mut spaces = 0u; + let mut spaces = 0; do str::all(line) |char| { // Only comparing against space because I wouldn't // know what to do with mixed whitespace chars if char == ' ' { - spaces += 1u; + spaces += 1; true } else { false } }; - uint::min(&min_indent, &spaces) + uint::min(min_indent, spaces) } }; diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs index 59b8be67ae7..f163a677582 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs @@ -4,7 +4,9 @@ import std::map::hashmap; import std::map; fn main() { - let buggy_map :hashmap = hashmap::(uint::hash, uint::eq); + let buggy_map :hashmap = + hashmap::(|x| { uint::hash(*x) }, + |x, y| { uint::eq(*x, *y) }); buggy_map.insert(42, ~1); //~ ERROR illegal borrow // but it is ok if we use a temporary