Make utility funs in core::int, core::uint, etc. not by-reference
Closes #3302
This commit is contained in:
parent
638db28c47
commit
4128cc4cb4
@ -249,18 +249,18 @@ fn check_variants_T<T: copy>(
|
||||
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
|
||||
|
@ -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 }
|
||||
|
@ -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`
|
||||
|
@ -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); }
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 }
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1427,7 +1427,7 @@ impl<T: Eq> @[T]: Eq {
|
||||
|
||||
pure fn lt<T: Ord>(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
|
||||
|
@ -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);
|
||||
|
@ -426,12 +426,12 @@ fn bytes_hash<V: copy>() -> hashmap<~[u8], V> {
|
||||
|
||||
/// Construct a hashmap for int keys
|
||||
fn int_hash<V: copy>() -> hashmap<int, V> {
|
||||
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<V: copy>() -> hashmap<uint, V> {
|
||||
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<V: copy>(items: &[(~[u8], V)]) -> hashmap<~[u8], V> {
|
||||
|
||||
/// Construct a hashmap from a vector with int keys
|
||||
fn hash_from_ints<V: copy>(items: &[(int, V)]) -> hashmap<int, V> {
|
||||
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<V: copy>(items: &[(uint, V)]) -> hashmap<uint, V> {
|
||||
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<K: Eq IterBytes Hash copy, V: copy> Managed<LinearMap<K, V>>:
|
||||
map<K, V> {
|
||||
pure fn size() -> uint {
|
||||
|
@ -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;
|
||||
|
@ -30,7 +30,7 @@ fn map_slices<A: copy send, B: copy send>(
|
||||
~[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<A: copy send, B: copy send>(
|
||||
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 ::<A, ()> annotation required here? (#2617)
|
||||
do vec::as_buf::<A, ()>(xs) |p, _len| {
|
||||
let f = f();
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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 = ~""; }
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 => {
|
||||
|
@ -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)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4,7 +4,9 @@ import std::map::hashmap;
|
||||
import std::map;
|
||||
|
||||
fn main() {
|
||||
let buggy_map :hashmap<uint, &uint> = hashmap::<uint, &uint>(uint::hash, uint::eq);
|
||||
let buggy_map :hashmap<uint, &uint> =
|
||||
hashmap::<uint, &uint>(|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
|
||||
|
Loading…
x
Reference in New Issue
Block a user