demode vec
This commit is contained in:
parent
6c15dd6d82
commit
21519bc7e0
@ -527,7 +527,7 @@ fn load_one_source_package(src: @Source, p: &json::Object) {
|
||||
Some(json::List(js)) => {
|
||||
for js.each |j| {
|
||||
match *j {
|
||||
json::String(j) => vec::grow(tags, 1u, j),
|
||||
json::String(ref j) => tags.grow(1u, j),
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
@ -503,10 +503,7 @@ fn make_run_args(config: config, _props: test_props, testfile: &Path) ->
|
||||
|
||||
fn split_maybe_args(argstr: Option<~str>) -> ~[~str] {
|
||||
fn rm_whitespace(v: ~[~str]) -> ~[~str] {
|
||||
fn flt(&&s: ~str) -> Option<~str> {
|
||||
if !str::is_whitespace(s) { option::Some(s) } else { option::None }
|
||||
}
|
||||
vec::filter_map(v, flt)
|
||||
vec::filter(v, |s| !str::is_whitespace(*s))
|
||||
}
|
||||
|
||||
match argstr {
|
||||
|
@ -229,7 +229,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: codemap::codemap,
|
||||
filename: &Path, cx: context) {
|
||||
let stolen = steal(crate, cx.mode);
|
||||
let extra_exprs = vec::filter(common_exprs(),
|
||||
|a| safe_to_use_expr(a, cx.mode) );
|
||||
|a| safe_to_use_expr(*a, cx.mode) );
|
||||
check_variants_T(crate, codemap, filename, ~"expr",
|
||||
extra_exprs + stolen.exprs, pprust::expr_to_str,
|
||||
replace_expr_in_crate, cx);
|
||||
|
@ -99,7 +99,7 @@ pub pure fn from_elem<T>(+data: T) -> DList<T> {
|
||||
|
||||
pub fn from_vec<T: Copy>(+vec: &[T]) -> DList<T> {
|
||||
do vec::foldl(DList(), vec) |list,data| {
|
||||
list.push(data); // Iterating left-to-right -- add newly to the tail.
|
||||
list.push(*data); // Iterating left-to-right -- add newly to the tail.
|
||||
list
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ impl<A> DVec<A> {
|
||||
fn pop() -> A {
|
||||
do self.check_out |v| {
|
||||
let mut v <- v;
|
||||
let result = vec::pop(v);
|
||||
let result = v.pop();
|
||||
self.give_back(move v);
|
||||
move result
|
||||
}
|
||||
@ -187,7 +187,7 @@ impl<A> DVec<A> {
|
||||
fn shift() -> A {
|
||||
do self.check_out |v| {
|
||||
let mut v = move v;
|
||||
let result = vec::shift(v);
|
||||
let result = v.shift();
|
||||
self.give_back(move v);
|
||||
move result
|
||||
}
|
||||
@ -305,10 +305,10 @@ impl<A: Copy> DVec<A> {
|
||||
* growing the vector if necessary. New elements will be initialized
|
||||
* with `initval`
|
||||
*/
|
||||
fn grow_set_elt(idx: uint, initval: A, +val: A) {
|
||||
fn grow_set_elt(idx: uint, initval: &A, +val: A) {
|
||||
do self.swap |v| {
|
||||
let mut v = move v;
|
||||
vec::grow_set(v, idx, initval, val);
|
||||
v.grow_set(idx, initval, val);
|
||||
move v
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ pub fn to_str_common(num: float, digits: uint, exact: bool) -> ~str {
|
||||
// turn digits into string
|
||||
// using stack of digits
|
||||
while fractionalParts.is_not_empty() {
|
||||
let mut adjusted_digit = carry + vec::pop(fractionalParts);
|
||||
let mut adjusted_digit = carry + fractionalParts.pop();
|
||||
|
||||
if adjusted_digit == 10 {
|
||||
carry = 1;
|
||||
|
@ -64,11 +64,11 @@ trait ReaderUtil {
|
||||
impl<T: Reader> T : ReaderUtil {
|
||||
fn read_bytes(len: uint) -> ~[u8] {
|
||||
let mut buf = vec::with_capacity(len);
|
||||
unsafe { vec::raw::set_len(buf, len); }
|
||||
unsafe { vec::raw::set_len(&mut buf, len); }
|
||||
|
||||
let count = self.read(buf, len);
|
||||
|
||||
unsafe { vec::raw::set_len(buf, count); }
|
||||
unsafe { vec::raw::set_len(&mut buf, count); }
|
||||
move buf
|
||||
}
|
||||
fn read_line() -> ~str {
|
||||
@ -695,7 +695,7 @@ impl BytesWriter: Writer {
|
||||
|
||||
let count = uint::max(buf_len, self.pos + v_len);
|
||||
vec::reserve(&mut buf, count);
|
||||
unsafe { vec::raw::set_len(buf, count); }
|
||||
unsafe { vec::raw::set_len(&mut buf, count); }
|
||||
|
||||
{
|
||||
let view = vec::mut_view(buf, self.pos, count);
|
||||
|
@ -582,7 +582,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
|
||||
fn star(p: &Path) -> Path { p.push("*") }
|
||||
|
||||
do rustrt::rust_list_files(star(p).to_str()).filter |filename| {
|
||||
filename != ~"." && filename != ~".."
|
||||
*filename != ~"." && *filename != ~".."
|
||||
}
|
||||
}
|
||||
|
||||
@ -857,10 +857,10 @@ mod tests {
|
||||
|
||||
let mut e = env();
|
||||
setenv(n, ~"VALUE");
|
||||
assert !vec::contains(e, (copy n, ~"VALUE"));
|
||||
assert !vec::contains(e, &(copy n, ~"VALUE"));
|
||||
|
||||
e = env();
|
||||
assert vec::contains(e, (n, ~"VALUE"));
|
||||
assert vec::contains(e, &(n, ~"VALUE"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -221,7 +221,7 @@ impl PosixPath : GenericPath {
|
||||
pure fn pop() -> PosixPath {
|
||||
let mut cs = copy self.components;
|
||||
if cs.len() != 0 {
|
||||
unsafe { vec::pop(cs); }
|
||||
unsafe { cs.pop(); }
|
||||
}
|
||||
return PosixPath { components: move cs, ..self }
|
||||
}
|
||||
@ -415,7 +415,7 @@ impl WindowsPath : GenericPath {
|
||||
pure fn pop() -> WindowsPath {
|
||||
let mut cs = copy self.components;
|
||||
if cs.len() != 0 {
|
||||
unsafe { vec::pop(cs); }
|
||||
unsafe { cs.pop(); }
|
||||
}
|
||||
return WindowsPath { components: move cs, ..self }
|
||||
}
|
||||
@ -437,7 +437,7 @@ pub pure fn normalize(components: &[~str]) -> ~[~str] {
|
||||
if *c == ~"." && components.len() > 1 { loop; }
|
||||
if *c == ~"" { loop; }
|
||||
if *c == ~".." && cs.len() != 0 {
|
||||
vec::pop(cs);
|
||||
cs.pop();
|
||||
loop;
|
||||
}
|
||||
cs.push(copy *c);
|
||||
|
@ -704,7 +704,7 @@ pub fn select<T: Send, Tb: Send>(+endpoints: ~[RecvPacketBuffered<T, Tb>])
|
||||
{
|
||||
let ready = wait_many(endpoints.map(|p| p.header()));
|
||||
let mut remaining <- endpoints;
|
||||
let port = vec::swap_remove(remaining, ready);
|
||||
let port = remaining.swap_remove(ready);
|
||||
let result = try_recv(move port);
|
||||
(ready, move result, move remaining)
|
||||
}
|
||||
@ -1067,7 +1067,7 @@ impl<T: Send> PortSet<T> : Recv<T> {
|
||||
}
|
||||
None => {
|
||||
// Remove this port.
|
||||
let _ = vec::swap_remove(ports, i);
|
||||
let _ = ports.swap_remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ pub unsafe fn memset<T>(dst: *mut T, c: int, count: uint) {
|
||||
reinterpret_cast.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub fn to_unsafe_ptr<T>(thing: &T) -> *T {
|
||||
pub pure fn to_unsafe_ptr<T>(thing: &T) -> *T {
|
||||
unsafe { cast::reinterpret_cast(&thing) }
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ pub fn to_unsafe_ptr<T>(thing: &T) -> *T {
|
||||
reinterpret_cast.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
|
||||
pub pure fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
|
||||
unsafe { cast::reinterpret_cast(&thing) }
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ pub fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
|
||||
reinterpret_cast.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
|
||||
pub pure fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
|
||||
unsafe { cast::reinterpret_cast(&thing) }
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ Section: Transforming strings
|
||||
*/
|
||||
pure fn to_bytes(s: &str) -> ~[u8] unsafe {
|
||||
let mut v: ~[u8] = ::cast::transmute(from_slice(s));
|
||||
vec::raw::set_len(v, len(s));
|
||||
vec::raw::set_len(&mut v, len(s));
|
||||
move v
|
||||
}
|
||||
|
||||
@ -1945,7 +1945,7 @@ fn reserve_at_least(s: &const ~str, n: uint) {
|
||||
*/
|
||||
pure fn capacity(s: &const ~str) -> uint {
|
||||
do as_bytes(s) |buf| {
|
||||
let vcap = vec::capacity(*buf);
|
||||
let vcap = vec::capacity(buf);
|
||||
assert vcap > 0u;
|
||||
vcap - 1u
|
||||
}
|
||||
@ -2008,7 +2008,7 @@ mod raw {
|
||||
vec::as_mut_buf(v, |vbuf, _len| {
|
||||
ptr::memcpy(vbuf, buf as *u8, len)
|
||||
});
|
||||
vec::raw::set_len(v, len);
|
||||
vec::raw::set_len(&mut v, len);
|
||||
v.push(0u8);
|
||||
|
||||
assert is_utf8(v);
|
||||
@ -2065,7 +2065,7 @@ mod raw {
|
||||
let src = ptr::offset(sbuf, begin);
|
||||
ptr::memcpy(vbuf, src, end - begin);
|
||||
}
|
||||
vec::raw::set_len(v, end - begin);
|
||||
vec::raw::set_len(&mut v, end - begin);
|
||||
v.push(0u8);
|
||||
::cast::transmute(move v)
|
||||
}
|
||||
|
@ -35,35 +35,44 @@ impl<T: Copy, U: Copy> (T, U): TupleOps<T,U> {
|
||||
}
|
||||
|
||||
trait ExtendedTupleOps<A,B> {
|
||||
fn zip() -> ~[(A, B)];
|
||||
fn map<C>(f: &fn(A, B) -> C) -> ~[C];
|
||||
fn zip(&self) -> ~[(A, B)];
|
||||
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C];
|
||||
}
|
||||
|
||||
impl<A: Copy, B: Copy> (&[A], &[B]): ExtendedTupleOps<A,B> {
|
||||
|
||||
fn zip() -> ~[(A, B)] {
|
||||
let (a, b) = self;
|
||||
vec::zip_slice(a, b)
|
||||
fn zip(&self) -> ~[(A, B)] {
|
||||
match *self {
|
||||
(ref a, ref b) => {
|
||||
vec::zip_slice(*a, *b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn map<C>(f: &fn(A, B) -> C) -> ~[C] {
|
||||
let (a, b) = self;
|
||||
vec::map2(a, b, f)
|
||||
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
|
||||
match *self {
|
||||
(ref a, ref b) => {
|
||||
vec::map2(*a, *b, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Copy, B: Copy> (~[A], ~[B]): ExtendedTupleOps<A,B> {
|
||||
|
||||
fn zip() -> ~[(A, B)] {
|
||||
// FIXME #2543: Bad copy
|
||||
let (a, b) = copy self;
|
||||
vec::zip(move a, move b)
|
||||
fn zip(&self) -> ~[(A, B)] {
|
||||
match *self {
|
||||
(ref a, ref b) => {
|
||||
vec::zip_slice(*a, *b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn map<C>(f: &fn(A, B) -> C) -> ~[C] {
|
||||
// FIXME #2543: Bad copy
|
||||
let (a, b) = copy self;
|
||||
vec::map2(a, b, f)
|
||||
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
|
||||
match *self {
|
||||
(ref a, ref b) => {
|
||||
vec::map2(*a, *b, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -217,7 +217,7 @@ impl Writer {
|
||||
}
|
||||
|
||||
fn end_tag() {
|
||||
let last_size_pos = vec::pop::<uint>(self.size_positions);
|
||||
let last_size_pos = self.size_positions.pop();
|
||||
let cur_pos = self.writer.tell();
|
||||
self.writer.seek(last_size_pos as int, io::SeekSet);
|
||||
let size = (cur_pos - last_size_pos - 4u);
|
||||
|
@ -226,7 +226,7 @@ impl Serializer {
|
||||
}
|
||||
|
||||
fn end_tag() {
|
||||
let last_size_pos = vec::pop::<uint>(self.size_positions);
|
||||
let last_size_pos = self.size_positions.pop();
|
||||
let cur_pos = self.writer.tell();
|
||||
self.writer.seek(last_size_pos as int, io::SeekSet);
|
||||
let size = (cur_pos - last_size_pos - 4u);
|
||||
|
@ -428,9 +428,8 @@ fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> {
|
||||
let vals = opt_vals(mm, nm);
|
||||
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
|
||||
return match vals[0] {
|
||||
Val(copy s) =>
|
||||
Some::<~str>(s),
|
||||
_ => None::<~str>
|
||||
Val(copy s) => Some(s),
|
||||
_ => None
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -696,7 +696,7 @@ priv impl Deserializer {
|
||||
|
||||
fn pop(&self) -> &self/Json {
|
||||
if self.stack.len() == 0 { self.stack.push(&self.json); }
|
||||
vec::pop(self.stack)
|
||||
self.stack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ enum List<T> {
|
||||
|
||||
/// Cregate a list from a vector
|
||||
fn from_vec<T: Copy>(v: &[T]) -> @List<T> {
|
||||
vec::foldr(v, @Nil::<T>, |h, t| @Cons(h, t))
|
||||
vec::foldr(v, @Nil::<T>, |h, t| @Cons(*h, t))
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,7 +163,7 @@ mod v4 {
|
||||
if vec::len(parts) != 4u {
|
||||
result::Err(fmt!("'%s' doesn't have 4 parts", ip))
|
||||
}
|
||||
else if vec::contains(parts, 256u) {
|
||||
else if vec::contains(parts, &256u) {
|
||||
result::Err(fmt!("invalid octal in addr '%s'", ip))
|
||||
}
|
||||
else {
|
||||
|
@ -800,7 +800,7 @@ impl TcpSocketBuf: io::Reader {
|
||||
if self.read(bytes, 1u) == 0 { fail } else { bytes[0] as int }
|
||||
}
|
||||
fn unread_byte(amt: int) {
|
||||
vec::unshift((*(self.data)).buf, amt as u8);
|
||||
self.data.buf.unshift(amt as u8);
|
||||
}
|
||||
fn eof() -> bool {
|
||||
false // noop
|
||||
|
@ -123,17 +123,17 @@ pub fn alli<A: Copy Send>(xs: ~[A], f: fn~(uint, A) -> bool) -> bool {
|
||||
do vec::all(map_slices(xs, || {
|
||||
fn~(base: uint, slice : &[A], copy f) -> bool {
|
||||
vec::alli(slice, |i, x| {
|
||||
f(i + base, x)
|
||||
f(i + base, *x)
|
||||
})
|
||||
}
|
||||
})) |x| { x }
|
||||
})) |x| { *x }
|
||||
}
|
||||
|
||||
/// Returns true if the function holds for any elements in the vector.
|
||||
pub fn any<A: Copy Send>(xs: ~[A], f: fn~(A) -> bool) -> bool {
|
||||
do vec::any(map_slices(xs, || {
|
||||
fn~(_base : uint, slice: &[A], copy f) -> bool {
|
||||
vec::any(slice, |x| f(x))
|
||||
vec::any(slice, |x| f(*x))
|
||||
}
|
||||
})) |x| { x }
|
||||
})) |x| { *x }
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ fn mk<T: Copy>() -> SmallIntMap<T> {
|
||||
#[inline(always)]
|
||||
fn insert<T: Copy>(self: SmallIntMap<T>, key: uint, +val: T) {
|
||||
//io::println(fmt!("%?", key));
|
||||
self.v.grow_set_elt(key, None, Some(val));
|
||||
self.v.grow_set_elt(key, &None, Some(val));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -358,7 +358,7 @@ fn filter_tests(opts: &TestOpts,
|
||||
} else { return option::None; }
|
||||
}
|
||||
|
||||
vec::filter_map(filtered, |x| filter_fn(&x, filter_str))
|
||||
vec::filter_map(filtered, |x| filter_fn(x, filter_str))
|
||||
};
|
||||
|
||||
// Maybe pull out the ignored test and unignore them
|
||||
@ -374,7 +374,7 @@ fn filter_tests(opts: &TestOpts,
|
||||
} else { return option::None; }
|
||||
};
|
||||
|
||||
vec::filter_map(filtered, |x| filter(&x))
|
||||
vec::filter_map(filtered, |x| filter(x))
|
||||
};
|
||||
|
||||
// Sort the tests alphabetically
|
||||
|
@ -278,7 +278,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
|
||||
_ => cx.path.push(path_name(i.ident))
|
||||
}
|
||||
visit::visit_item(i, cx, v);
|
||||
vec::pop(cx.path);
|
||||
cx.path.pop();
|
||||
}
|
||||
|
||||
fn map_struct_def(struct_def: @ast::struct_def, parent_node: ast_node,
|
||||
|
@ -275,14 +275,14 @@ fn ident_to_path(s: span, +i: ident) -> @path {
|
||||
rp: None, types: ~[]}
|
||||
}
|
||||
|
||||
pure fn is_unguarded(&&a: arm) -> bool {
|
||||
pure fn is_unguarded(a: &arm) -> bool {
|
||||
match a.guard {
|
||||
None => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pure fn unguarded_pat(a: arm) -> Option<~[@pat]> {
|
||||
pure fn unguarded_pat(a: &arm) -> Option<~[@pat]> {
|
||||
if is_unguarded(a) { Some(/* FIXME (#2543) */ copy a.pats) } else { None }
|
||||
}
|
||||
|
||||
|
@ -163,9 +163,9 @@ fn get_name_value_str_pair(item: @ast::meta_item) -> Option<(~str, ~str)> {
|
||||
fn find_attrs_by_name(attrs: ~[ast::attribute], name: ~str) ->
|
||||
~[ast::attribute] {
|
||||
let filter = (
|
||||
fn@(a: ast::attribute) -> Option<ast::attribute> {
|
||||
if get_attr_name(a) == name {
|
||||
option::Some(a)
|
||||
fn@(a: &ast::attribute) -> Option<ast::attribute> {
|
||||
if get_attr_name(*a) == name {
|
||||
option::Some(*a)
|
||||
} else { option::None }
|
||||
}
|
||||
);
|
||||
@ -175,9 +175,9 @@ fn find_attrs_by_name(attrs: ~[ast::attribute], name: ~str) ->
|
||||
/// Searcha list of meta items and return only those with a specific name
|
||||
fn find_meta_items_by_name(metas: ~[@ast::meta_item], name: ~str) ->
|
||||
~[@ast::meta_item] {
|
||||
let filter = fn@(&&m: @ast::meta_item) -> Option<@ast::meta_item> {
|
||||
if get_meta_item_name(m) == name {
|
||||
option::Some(m)
|
||||
let filter = fn@(m: &@ast::meta_item) -> Option<@ast::meta_item> {
|
||||
if get_meta_item_name(*m) == name {
|
||||
option::Some(*m)
|
||||
} else { option::None }
|
||||
};
|
||||
return vec::filter_map(metas, filter);
|
||||
@ -289,8 +289,8 @@ fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ~str) ->
|
||||
~[@ast::meta_item] {
|
||||
|
||||
return vec::filter_map(items, |item| {
|
||||
if get_meta_item_name(item) != name {
|
||||
option::Some(/* FIXME (#2543) */ copy item)
|
||||
if get_meta_item_name(*item) != name {
|
||||
option::Some(/* FIXME (#2543) */ copy *item)
|
||||
} else {
|
||||
option::None
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ fn expand(cx: ext_ctxt,
|
||||
span: span,
|
||||
_mitem: ast::meta_item,
|
||||
in_items: ~[@ast::item]) -> ~[@ast::item] {
|
||||
fn not_auto_serialize(a: ast::attribute) -> bool {
|
||||
attr::get_attr_name(a) != ~"auto_serialize"
|
||||
fn not_auto_serialize(a: &ast::attribute) -> bool {
|
||||
attr::get_attr_name(*a) != ~"auto_serialize"
|
||||
}
|
||||
|
||||
fn filter_attrs(item: @ast::item) -> @ast::item {
|
||||
@ -102,12 +102,12 @@ fn expand(cx: ext_ctxt,
|
||||
do vec::flat_map(in_items) |in_item| {
|
||||
match in_item.node {
|
||||
ast::item_ty(ty, tps) => {
|
||||
vec::append(~[filter_attrs(in_item)],
|
||||
vec::append(~[filter_attrs(*in_item)],
|
||||
ty_fns(cx, in_item.ident, ty, tps))
|
||||
}
|
||||
|
||||
ast::item_enum(enum_definition, tps) => {
|
||||
vec::append(~[filter_attrs(in_item)],
|
||||
vec::append(~[filter_attrs(*in_item)],
|
||||
enum_fns(cx, in_item.ident,
|
||||
in_item.span, enum_definition.variants, tps))
|
||||
}
|
||||
@ -116,7 +116,7 @@ fn expand(cx: ext_ctxt,
|
||||
cx.span_err(span, ~"#[auto_serialize] can only be \
|
||||
applied to type and enum \
|
||||
definitions");
|
||||
~[in_item]
|
||||
~[*in_item]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ fn expand(cx: ext_ctxt,
|
||||
span: span,
|
||||
_mitem: ast::meta_item,
|
||||
in_items: ~[@ast::item]) -> ~[@ast::item] {
|
||||
fn not_auto_serialize2(a: ast::attribute) -> bool {
|
||||
attr::get_attr_name(a) != ~"auto_serialize2"
|
||||
fn not_auto_serialize2(a: &ast::attribute) -> bool {
|
||||
attr::get_attr_name(*a) != ~"auto_serialize2"
|
||||
}
|
||||
|
||||
fn filter_attrs(item: @ast::item) -> @ast::item {
|
||||
@ -88,19 +88,19 @@ fn expand(cx: ext_ctxt,
|
||||
match item.node {
|
||||
ast::item_ty(@{node: ast::ty_rec(fields), _}, tps) => {
|
||||
~[
|
||||
filter_attrs(item),
|
||||
filter_attrs(*item),
|
||||
mk_rec_impl(cx, item.span, item.ident, fields, tps),
|
||||
]
|
||||
},
|
||||
ast::item_class(@{ fields, _}, tps) => {
|
||||
~[
|
||||
filter_attrs(item),
|
||||
filter_attrs(*item),
|
||||
mk_struct_impl(cx, item.span, item.ident, fields, tps),
|
||||
]
|
||||
},
|
||||
ast::item_enum(enum_def, tps) => {
|
||||
~[
|
||||
filter_attrs(item),
|
||||
filter_attrs(*item),
|
||||
mk_enum_impl(cx, item.span, item.ident, enum_def, tps),
|
||||
]
|
||||
},
|
||||
@ -108,7 +108,7 @@ fn expand(cx: ext_ctxt,
|
||||
cx.span_err(span, ~"#[auto_serialize2] can only be applied \
|
||||
to structs, record types, and enum \
|
||||
definitions");
|
||||
~[item]
|
||||
~[*item]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess,
|
||||
fn print_backtrace() { }
|
||||
fn backtrace() -> expn_info { self.backtrace }
|
||||
fn mod_push(i: ast::ident) { self.mod_path.push(i); }
|
||||
fn mod_pop() { vec::pop(self.mod_path); }
|
||||
fn mod_pop() { self.mod_path.pop(); }
|
||||
fn mod_path() -> ~[ast::ident] { return self.mod_path; }
|
||||
fn bt_push(ei: codemap::expn_info_) {
|
||||
match ei {
|
||||
|
@ -144,7 +144,7 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
|
||||
// decorated with "item decorators", then use that function to transform
|
||||
// the item into a new set of items.
|
||||
let new_items = do vec::flat_map(module_.items) |item| {
|
||||
do vec::foldr(item.attrs, ~[item]) |attr, items| {
|
||||
do vec::foldr(item.attrs, ~[*item]) |attr, items| {
|
||||
let mname = match attr.node.value.node {
|
||||
ast::meta_word(n) => n,
|
||||
ast::meta_name_value(n, _) => n,
|
||||
@ -160,7 +160,7 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
|
||||
}
|
||||
};
|
||||
|
||||
return {items: new_items,.. module_};
|
||||
return {items: new_items, ..module_};
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ impl message: gen_send {
|
||||
let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
|
||||
|
||||
let args_ast = (arg_names, tys).map(
|
||||
|n, t| cx.arg_mode(n, t, ast::by_copy)
|
||||
|n, t| cx.arg_mode(*n, *t, ast::by_copy)
|
||||
);
|
||||
|
||||
let pipe_ty = cx.ty_path_ast_builder(
|
||||
@ -129,7 +129,7 @@ impl message: gen_send {
|
||||
let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str()));
|
||||
|
||||
let args_ast = (arg_names, tys).map(
|
||||
|n, t| cx.arg_mode(cx.ident_of(n), t, ast::by_copy)
|
||||
|n, t| cx.arg_mode(cx.ident_of(*n), *t, ast::by_copy)
|
||||
);
|
||||
|
||||
let args_ast = vec::append(
|
||||
|
@ -307,7 +307,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
|
||||
while idx < rc {
|
||||
idx_path.push(idx);
|
||||
res.push(recur(repeat_me)); // whew!
|
||||
vec::pop(*idx_path);
|
||||
idx_path.pop();
|
||||
idx += 1u;
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
|
||||
|
||||
/* we append new items to this while we go */
|
||||
while cur_eis.len() > 0u { /* for each Earley Item */
|
||||
let mut ei = vec::pop(cur_eis);
|
||||
let mut ei = cur_eis.pop();
|
||||
|
||||
let idx = ei.idx;
|
||||
let len = ei.elts.len();
|
||||
@ -350,13 +350,13 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
|
||||
} else if (next_eis.len() > 0u) {
|
||||
/* Now process the next token */
|
||||
while(next_eis.len() > 0u) {
|
||||
cur_eis.push(vec::pop(next_eis));
|
||||
cur_eis.push(next_eis.pop());
|
||||
}
|
||||
rdr.next_token();
|
||||
} else /* bb_eis.len() == 1 */ {
|
||||
let rust_parser = parser(sess, cfg, rdr.dup(), SOURCE_FILE);
|
||||
|
||||
let ei = vec::pop(bb_eis);
|
||||
let ei = bb_eis.pop();
|
||||
match ei.elts[ei.idx].node {
|
||||
match_nonterminal(_, name, idx) => {
|
||||
ei.matches[idx].push(@matched_nonterminal(
|
||||
|
@ -82,13 +82,13 @@ pure fn dup_tt_reader(&&r: tt_reader) -> tt_reader {
|
||||
|
||||
pure fn lookup_cur_matched_by_matched(r: tt_reader,
|
||||
start: @named_match) -> @named_match {
|
||||
pure fn red(&&ad: @named_match, &&idx: uint) -> @named_match {
|
||||
pure fn red(+ad: @named_match, idx: &uint) -> @named_match {
|
||||
match *ad {
|
||||
matched_nonterminal(_) => {
|
||||
// end of the line; duplicate henceforth
|
||||
ad
|
||||
}
|
||||
matched_seq(ads, _) => ads[idx]
|
||||
matched_seq(ads, _) => ads[*idx]
|
||||
}
|
||||
}
|
||||
vec::foldl(start, r.repeat_idx, red)
|
||||
@ -122,8 +122,8 @@ fn lockstep_iter_size(t: token_tree, r: tt_reader) -> lis {
|
||||
}
|
||||
match t {
|
||||
tt_delim(tts) | tt_seq(_, tts, _, _) => {
|
||||
vec::foldl(lis_unconstrained, tts, {|lis, tt|
|
||||
lis_merge(lis, lockstep_iter_size(tt, r), r) })
|
||||
vec::foldl(lis_unconstrained, tts, |lis, tt|
|
||||
lis_merge(lis, lockstep_iter_size(*tt, r), r))
|
||||
}
|
||||
tt_tok(*) => lis_unconstrained,
|
||||
tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) {
|
||||
@ -148,7 +148,8 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} {
|
||||
}
|
||||
tt_frame_up(Some(tt_f)) => {
|
||||
if r.cur.dotdotdoted {
|
||||
vec::pop(r.repeat_idx); vec::pop(r.repeat_len);
|
||||
r.repeat_idx.pop();
|
||||
r.repeat_len.pop();
|
||||
}
|
||||
|
||||
r.cur = tt_f;
|
||||
|
@ -552,7 +552,7 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
|
||||
// ...nor do modules
|
||||
fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
|
||||
return {view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)),
|
||||
items: vec::filter_map(m.items, |x| fld.fold_item(x))};
|
||||
items: vec::filter_map(m.items, |x| fld.fold_item(*x))};
|
||||
}
|
||||
|
||||
fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod {
|
||||
|
@ -1111,7 +1111,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||
ast::expr_call(func, args, has_block) => {
|
||||
let mut base_args = args;
|
||||
let blk = if has_block {
|
||||
let blk_arg = vec::pop(base_args);
|
||||
let blk_arg = base_args.pop();
|
||||
match blk_arg.node {
|
||||
ast::expr_loop_body(_) => { head(s, ~"for"); }
|
||||
ast::expr_do_body(_) => { head(s, ~"do"); }
|
||||
|
@ -122,7 +122,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
|
||||
logging::console_off();
|
||||
|
||||
let mut args = args;
|
||||
let binary = vec::shift(args);
|
||||
let binary = args.shift();
|
||||
|
||||
if vec::len(args) == 0u { usage(binary); return; }
|
||||
|
||||
|
@ -50,13 +50,12 @@ fn filter_view_item(cx: ctxt, &&view_item: @ast::view_item
|
||||
|
||||
fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) ->
|
||||
ast::_mod {
|
||||
let item_filter = |a| filter_item(cx, a);
|
||||
let filtered_items = vec::filter_map(m.items, item_filter);
|
||||
let view_item_filter = |a| filter_view_item(cx, a);
|
||||
let filtered_view_items = vec::filter_map(m.view_items, view_item_filter);
|
||||
let filtered_items = vec::filter_map(m.items, |a| filter_item(cx, *a));
|
||||
let filtered_view_items = vec::filter_map(m.view_items,
|
||||
|a| filter_view_item(cx, *a));
|
||||
return {
|
||||
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
|
||||
items: vec::filter_map(filtered_items, |x| fld.fold_item(x))
|
||||
items: vec::filter_map(filtered_items, |x| fld.fold_item(*x))
|
||||
};
|
||||
}
|
||||
|
||||
@ -69,11 +68,10 @@ fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) ->
|
||||
|
||||
fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod,
|
||||
fld: fold::ast_fold) -> ast::foreign_mod {
|
||||
let item_filter = |a| filter_foreign_item(cx, a);
|
||||
let filtered_items = vec::filter_map(nm.items, item_filter);
|
||||
let view_item_filter = |a| filter_view_item(cx, a);
|
||||
let filtered_view_items = vec::filter_map(
|
||||
nm.view_items, view_item_filter);
|
||||
let filtered_items = vec::filter_map(nm.items,
|
||||
|a| filter_foreign_item(cx, *a));
|
||||
let filtered_view_items = vec::filter_map(nm.view_items,
|
||||
|a| filter_view_item(cx, *a));
|
||||
return {
|
||||
sort: nm.sort,
|
||||
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
|
||||
@ -100,8 +98,7 @@ fn filter_stmt(cx: ctxt, &&stmt: @ast::stmt) ->
|
||||
|
||||
fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) ->
|
||||
ast::blk_ {
|
||||
let filter = |a| filter_stmt(cx, a);
|
||||
let filtered_stmts = vec::filter_map(b.stmts, filter);
|
||||
let filtered_stmts = vec::filter_map(b.stmts, |a| filter_stmt(cx, *a));
|
||||
return {view_items: b.view_items,
|
||||
stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
|
||||
expr: option::map(&b.expr, |x| fld.fold_expr(*x)),
|
||||
@ -136,7 +133,7 @@ fn metas_in_cfg(cfg: ast::crate_cfg, metas: ~[@ast::meta_item]) -> bool {
|
||||
// so we can match against them. This is the list of configurations for
|
||||
// which the item is valid
|
||||
let cfg_metas = vec::concat(vec::filter_map(cfg_metas,
|
||||
|&&i| attr::get_meta_item_list(i) ));
|
||||
|i| attr::get_meta_item_list(*i)));
|
||||
|
||||
let has_cfg_metas = vec::len(cfg_metas) > 0u;
|
||||
if !has_cfg_metas { return true; }
|
||||
|
@ -81,8 +81,8 @@ fn fold_mod(cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
|
||||
}
|
||||
|
||||
let mod_nomain =
|
||||
{view_items: m.view_items, items: vec::filter_map(m.items,
|
||||
|i| nomain(cx, i))};
|
||||
{view_items: m.view_items,
|
||||
items: vec::filter_map(m.items, |i| nomain(cx, *i))};
|
||||
return fold::noop_fold_mod(mod_nomain, fld);
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) ->
|
||||
}
|
||||
|
||||
let res = fold::noop_fold_item(i, fld);
|
||||
vec::pop(cx.path);
|
||||
cx.path.pop();
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool {
|
||||
let ignoreattrs = attr::find_attrs_by_name(i.attrs, ~"ignore");
|
||||
let ignoreitems = attr::attr_metas(ignoreattrs);
|
||||
let cfg_metas = vec::concat(vec::filter_map(ignoreitems,
|
||||
|&&i| attr::get_meta_item_list(i) ));
|
||||
|i| attr::get_meta_item_list(*i)));
|
||||
return if vec::is_not_empty(ignoreitems) {
|
||||
config::metas_in_cfg(cx.crate.node.config, cfg_metas)
|
||||
} else {
|
||||
|
@ -114,7 +114,7 @@ fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) {
|
||||
}
|
||||
|
||||
fn add_used_crate_file(cstore: cstore, lib: &Path) {
|
||||
if !vec::contains(p(cstore).used_crate_files, copy *lib) {
|
||||
if !vec::contains(p(cstore).used_crate_files, lib) {
|
||||
p(cstore).used_crate_files.push(copy *lib);
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ fn get_used_crate_files(cstore: cstore) -> ~[Path] {
|
||||
fn add_used_library(cstore: cstore, lib: ~str) -> bool {
|
||||
assert lib != ~"";
|
||||
|
||||
if vec::contains(p(cstore).used_libraries, lib) { return false; }
|
||||
if vec::contains(p(cstore).used_libraries, &lib) { return false; }
|
||||
p(cstore).used_libraries.push(lib);
|
||||
return true;
|
||||
}
|
||||
|
@ -980,7 +980,7 @@ fn get_crate_module_paths(intr: @ident_interner, cdata: cmd)
|
||||
res.push((did, path));
|
||||
}
|
||||
return do vec::filter(res) |x| {
|
||||
let (_, xp) = x;
|
||||
let (_, xp) = *x;
|
||||
mods.contains_key(xp)
|
||||
}
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ impl check_loan_ctxt {
|
||||
do vec::iter2(args, arg_tys) |arg, arg_ty| {
|
||||
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
||||
ast::by_move => {
|
||||
self.check_move_out(arg);
|
||||
self.check_move_out(*arg);
|
||||
}
|
||||
ast::by_mutbl_ref | ast::by_ref |
|
||||
ast::by_copy | ast::by_val => {
|
||||
|
@ -116,11 +116,11 @@ fn req_loans_in_expr(ex: @ast::expr,
|
||||
do vec::iter2(args, arg_tys) |arg, arg_ty| {
|
||||
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
||||
ast::by_mutbl_ref => {
|
||||
let arg_cmt = self.bccx.cat_expr(arg);
|
||||
let arg_cmt = self.bccx.cat_expr(*arg);
|
||||
self.guarantee_valid(arg_cmt, m_mutbl, scope_r);
|
||||
}
|
||||
ast::by_ref => {
|
||||
let arg_cmt = self.bccx.cat_expr(arg);
|
||||
let arg_cmt = self.bccx.cat_expr(*arg);
|
||||
self.guarantee_valid(arg_cmt, m_imm, scope_r);
|
||||
}
|
||||
ast::by_val => {
|
||||
|
@ -195,7 +195,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
||||
}
|
||||
}
|
||||
Some(ctor) => {
|
||||
match is_useful(tcx, vec::filter_map(m, |r| default(tcx, r) ),
|
||||
match is_useful(tcx, vec::filter_map(m, |r| default(tcx, *r) ),
|
||||
vec::tail(v)) {
|
||||
useful_ => useful(left_ty, ctor),
|
||||
u => u
|
||||
@ -212,7 +212,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
||||
|
||||
fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor,
|
||||
arity: uint, lty: ty::t) -> useful {
|
||||
let ms = vec::filter_map(m, |r| specialize(tcx, r, ctor, arity, lty) );
|
||||
let ms = vec::filter_map(m, |r| specialize(tcx, *r, ctor, arity, lty) );
|
||||
let could_be_useful = is_useful(
|
||||
tcx, ms, specialize(tcx, v, ctor, arity, lty).get());
|
||||
match could_be_useful {
|
||||
@ -269,7 +269,9 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option<ctor> {
|
||||
let mut found = ~[];
|
||||
for m.each |r| {
|
||||
do option::iter(&pat_ctor_id(tcx, r[0])) |id| {
|
||||
if !vec::contains(found, *id) { found.push(*id); }
|
||||
if !vec::contains(found, id) {
|
||||
found.push(*id);
|
||||
}
|
||||
}
|
||||
}
|
||||
let variants = ty::enum_variants(tcx, eid);
|
||||
|
@ -41,7 +41,7 @@ enum constness {
|
||||
}
|
||||
|
||||
fn join(a: constness, b: constness) -> constness {
|
||||
match (a,b) {
|
||||
match (a, b) {
|
||||
(integral_const, integral_const) => integral_const,
|
||||
(integral_const, general_const)
|
||||
| (general_const, integral_const)
|
||||
@ -51,7 +51,7 @@ fn join(a: constness, b: constness) -> constness {
|
||||
}
|
||||
|
||||
fn join_all(cs: &[constness]) -> constness {
|
||||
vec::foldl(integral_const, cs, join)
|
||||
vec::foldl(integral_const, cs, |a, b| join(a, *b))
|
||||
}
|
||||
|
||||
fn classify(e: @expr,
|
||||
|
@ -273,7 +273,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
*bounds, (*bounds).len());
|
||||
}
|
||||
do vec::iter2(*ts, *bounds) |ty, bound| {
|
||||
check_bounds(cx, id_to_use, e.span, ty, bound)
|
||||
check_bounds(cx, id_to_use, e.span, *ty, *bound)
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) {
|
||||
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id));
|
||||
let bounds = ty::lookup_item_type(cx.tcx, did).bounds;
|
||||
do vec::iter2(*ts, *bounds) |ty, bound| {
|
||||
check_bounds(cx, aty.id, aty.span, ty, bound)
|
||||
check_bounds(cx, aty.id, aty.span, *ty, *bound)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -955,7 +955,7 @@ impl Liveness {
|
||||
fn propagate_through_block(blk: blk, succ: LiveNode) -> LiveNode {
|
||||
let succ = self.propagate_through_opt_expr(blk.node.expr, succ);
|
||||
do blk.node.stmts.foldr(succ) |stmt, succ| {
|
||||
self.propagate_through_stmt(stmt, succ)
|
||||
self.propagate_through_stmt(*stmt, succ)
|
||||
}
|
||||
}
|
||||
|
||||
@ -975,7 +975,7 @@ impl Liveness {
|
||||
match decl.node {
|
||||
decl_local(locals) => {
|
||||
do locals.foldr(succ) |local, succ| {
|
||||
self.propagate_through_local(local, succ)
|
||||
self.propagate_through_local(*local, succ)
|
||||
}
|
||||
}
|
||||
decl_item(_) => {
|
||||
@ -1007,7 +1007,7 @@ impl Liveness {
|
||||
fn propagate_through_exprs(exprs: ~[@expr],
|
||||
succ: LiveNode) -> LiveNode {
|
||||
do exprs.foldr(succ) |expr, succ| {
|
||||
self.propagate_through_expr(expr, succ)
|
||||
self.propagate_through_expr(*expr, succ)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1575,7 +1575,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
|
||||
match ty::resolved_mode(self.tcx, arg_ty.mode) {
|
||||
by_val | by_copy | by_ref | by_mutbl_ref => {}
|
||||
by_move => {
|
||||
self.check_move_from_expr(arg_expr, vt);
|
||||
self.check_move_from_expr(*arg_expr, vt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1560,7 +1560,7 @@ impl Resolver {
|
||||
path_entry.def_like);
|
||||
|
||||
let mut pieces = split_str(path_entry.path_string, ~"::");
|
||||
let final_ident_str = pop(pieces);
|
||||
let final_ident_str = pieces.pop();
|
||||
let final_ident = self.session.ident_of(final_ident_str);
|
||||
|
||||
// Find the module we need, creating modules along the way if we
|
||||
|
@ -581,7 +581,7 @@ fn collect_record_or_struct_fields(m: &[@Match], col: uint) -> ~[ast::ident] {
|
||||
fn extend(idents: &mut ~[ast::ident], field_pats: &[ast::field_pat]) {
|
||||
for field_pats.each |field_pat| {
|
||||
let field_ident = field_pat.ident;
|
||||
if !vec::any(*idents, |x| x == field_ident) {
|
||||
if !vec::any(*idents, |x| *x == field_ident) {
|
||||
idents.push(field_ident);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ struct icx_popper {
|
||||
ccx: @crate_ctxt,
|
||||
drop {
|
||||
if self.ccx.sess.count_llvm_insns() {
|
||||
vec::pop(*(self.ccx.stats.llvm_insn_ctxt));
|
||||
self.ccx.stats.llvm_insn_ctxt.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ fn revoke_clean(cx: block, val: ValueRef) {
|
||||
do in_scope_cx(cx) |info| {
|
||||
let cleanup_pos = vec::position(
|
||||
info.cleanups,
|
||||
|cu| match cu {
|
||||
|cu| match *cu {
|
||||
clean_temp(v, _, _) if v == val => true,
|
||||
_ => false
|
||||
});
|
||||
|
@ -158,7 +158,7 @@ fn trans_log(log_ex: @ast::expr,
|
||||
let modpath = vec::append(
|
||||
~[path_mod(ccx.sess.ident_of(ccx.link_meta.name))],
|
||||
vec::filter(bcx.fcx.path, |e|
|
||||
match e { path_mod(_) => true, _ => false }
|
||||
match *e { path_mod(_) => true, _ => false }
|
||||
));
|
||||
let modname = path_str(ccx.sess, modpath);
|
||||
|
||||
|
@ -92,7 +92,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
||||
Double => 8,
|
||||
Struct => {
|
||||
do vec::foldl(0, struct_tys(ty)) |a, t| {
|
||||
uint::max(a, ty_align(t))
|
||||
uint::max(a, ty_align(*t))
|
||||
}
|
||||
}
|
||||
Array => {
|
||||
@ -113,7 +113,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
||||
Double => 8,
|
||||
Struct => {
|
||||
do vec::foldl(0, struct_tys(ty)) |s, t| {
|
||||
s + ty_size(t)
|
||||
s + ty_size(*t)
|
||||
}
|
||||
}
|
||||
Array => {
|
||||
|
@ -33,7 +33,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
|
||||
let param_uses = type_use::type_uses_for(ccx, fn_id, substs.len());
|
||||
let hash_id = make_mono_id(ccx, fn_id, substs, vtables, Some(param_uses));
|
||||
if vec::any(hash_id.params,
|
||||
|p| match p { mono_precise(_, _) => false, _ => true }) {
|
||||
|p| match *p { mono_precise(_, _) => false, _ => true }) {
|
||||
must_cast = true;
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
||||
let mut i = 0u;
|
||||
vec::map2(*bounds, substs, |bounds, subst| {
|
||||
let mut v = ~[];
|
||||
for vec::each(*bounds) |bound| {
|
||||
for bounds.each |bound| {
|
||||
match *bound {
|
||||
ty::bound_trait(_) => {
|
||||
v.push(meth::vtable_id(ccx, vts[i]));
|
||||
@ -252,7 +252,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
(subst, if v.len() > 0u { Some(v) } else { None })
|
||||
(*subst, if v.len() > 0u { Some(v) } else { None })
|
||||
})
|
||||
}
|
||||
None => {
|
||||
@ -262,12 +262,12 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
||||
let param_ids = match param_uses {
|
||||
Some(uses) => {
|
||||
vec::map2(precise_param_ids, uses, |id, uses| {
|
||||
match id {
|
||||
match *id {
|
||||
(a, b@Some(_)) => mono_precise(a, b),
|
||||
(subst, None) => {
|
||||
if uses == 0u {
|
||||
if *uses == 0u {
|
||||
mono_any
|
||||
} else if uses == type_use::use_repr &&
|
||||
} else if *uses == type_use::use_repr &&
|
||||
!ty::type_needs_drop(ccx.tcx, subst)
|
||||
{
|
||||
let llty = type_of::type_of(ccx, subst);
|
||||
|
@ -206,7 +206,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
||||
let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get(e.id));
|
||||
vec::iter2(type_uses_for(cx.ccx, id, ts.len()), *ts,
|
||||
|uses, subst| {
|
||||
type_needs(cx, uses, subst)
|
||||
type_needs(cx, *uses, *subst)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -239,7 +239,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
||||
typeck::method_static(did) => {
|
||||
do cx.ccx.tcx.node_type_substs.find(e.id).iter |ts| {
|
||||
do vec::iter2(type_uses_for(cx.ccx, did, ts.len()), *ts)
|
||||
|uses, subst| { type_needs(cx, uses, subst)}
|
||||
|uses, subst| { type_needs(cx, *uses, *subst)}
|
||||
}
|
||||
}
|
||||
typeck::method_param({param_num: param, _}) => {
|
||||
|
@ -2238,7 +2238,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
ty_class(did, _) if vec::contains(*seen, did) => {
|
||||
ty_class(ref did, _) if vec::contains(*seen, did) => {
|
||||
false
|
||||
}
|
||||
|
||||
@ -2246,15 +2246,15 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
|
||||
seen.push(did);
|
||||
let r = vec::any(class_items_as_fields(cx, did, substs),
|
||||
|f| type_requires(cx, seen, r_ty, f.mt.ty));
|
||||
vec::pop(*seen);
|
||||
seen.pop();
|
||||
r
|
||||
}
|
||||
|
||||
ty_tup(ts) => {
|
||||
vec::any(ts, |t| type_requires(cx, seen, r_ty, t))
|
||||
vec::any(ts, |t| type_requires(cx, seen, r_ty, *t))
|
||||
}
|
||||
|
||||
ty_enum(did, _) if vec::contains(*seen, did) => {
|
||||
ty_enum(ref did, _) if vec::contains(*seen, did) => {
|
||||
false
|
||||
}
|
||||
|
||||
@ -2263,11 +2263,11 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
|
||||
let vs = enum_variants(cx, did);
|
||||
let r = vec::len(*vs) > 0u && vec::all(*vs, |variant| {
|
||||
vec::any(variant.args, |aty| {
|
||||
let sty = subst(cx, substs, aty);
|
||||
let sty = subst(cx, substs, *aty);
|
||||
type_requires(cx, seen, r_ty, sty)
|
||||
})
|
||||
});
|
||||
vec::pop(*seen);
|
||||
seen.pop();
|
||||
r
|
||||
}
|
||||
};
|
||||
@ -3063,7 +3063,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: TyVid, rt: t) {
|
||||
if !type_needs_infer(rt) { return; }
|
||||
|
||||
// Occurs check!
|
||||
if vec::contains(vars_in_type(rt), vid) {
|
||||
if vec::contains(vars_in_type(rt), &vid) {
|
||||
// Maybe this should be span_err -- however, there's an
|
||||
// assertion later on that the type doesn't contain
|
||||
// variables, so in this case we have to be sure to die.
|
||||
|
@ -309,7 +309,7 @@ fn check_fn(ccx: @crate_ctxt,
|
||||
fcx.write_ty(info.self_id, info.self_ty);
|
||||
}
|
||||
do vec::iter2(decl.inputs, arg_tys) |input, arg| {
|
||||
fcx.write_ty(input.id, arg);
|
||||
fcx.write_ty(input.id, *arg);
|
||||
}
|
||||
|
||||
// If we don't have any enclosing function scope, it is time to
|
||||
@ -352,7 +352,7 @@ fn check_fn(ccx: @crate_ctxt,
|
||||
|
||||
// Add formal parameters.
|
||||
do vec::iter2(arg_tys, decl.inputs) |arg_ty, input| {
|
||||
assign(input.ty.span, input.id, Some(arg_ty));
|
||||
assign(input.ty.span, input.id, Some(*arg_ty));
|
||||
debug!("Argument %s is assigned to %s",
|
||||
tcx.sess.str_of(input.ident),
|
||||
fcx.inh.locals.get(input.id).to_str());
|
||||
@ -807,7 +807,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> (ty::t, uint) {
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
ty::ty_enum(did, _) => {
|
||||
ty::ty_enum(ref did, _) => {
|
||||
// Watch out for a type like `enum t = @t`. Such a
|
||||
// type would otherwise infinitely auto-deref. Only
|
||||
// autoderef loops during typeck (basically, this one
|
||||
@ -818,7 +818,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> (ty::t, uint) {
|
||||
if vec::contains(enum_dids, did) {
|
||||
return (t1, autoderefs);
|
||||
}
|
||||
enum_dids.push(did);
|
||||
enum_dids.push(*did);
|
||||
}
|
||||
_ => { /*ok*/ }
|
||||
}
|
||||
@ -2294,7 +2294,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
if vec::contains(*disr_vals, *disr_val) {
|
||||
if vec::contains(*disr_vals, &*disr_val) {
|
||||
ccx.tcx.sess.span_err(v.span,
|
||||
~"discriminator value already exists");
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
||||
|
||||
do subpats.iter() |pats| {
|
||||
do vec::iter2(*pats, arg_types) |subpat, arg_ty| {
|
||||
check_pat(pcx, subpat, arg_ty);
|
||||
check_pat(pcx, *subpat, *arg_ty);
|
||||
}
|
||||
};
|
||||
} else if subpats_len > 0u {
|
||||
|
@ -23,7 +23,7 @@ use util::common::indenter;
|
||||
|
||||
fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool {
|
||||
vec::any(tps, |bs| {
|
||||
vec::any(*bs, |b| {
|
||||
bs.any(|b| {
|
||||
match b { ty::bound_trait(_) => true, _ => false }
|
||||
})
|
||||
})
|
||||
@ -393,7 +393,7 @@ fn connect_trait_tps(fcx: @fn_ctxt, expr: @ast::expr, impl_tys: ~[ty::t],
|
||||
match ty::get(trait_ty).sty {
|
||||
ty::ty_trait(_, substs, _) => {
|
||||
vec::iter2(substs.tps, trait_tys,
|
||||
|a, b| demand::suptype(fcx, expr.span, a, b));
|
||||
|a, b| demand::suptype(fcx, expr.span, *a, *b));
|
||||
}
|
||||
_ => tcx.sess.impossible_case(expr.span, "connect_trait_tps: \
|
||||
don't know how to handle a non-trait ty")
|
||||
|
@ -725,7 +725,7 @@ fn ty_of_foreign_item(ccx: @crate_ctxt, it: @ast::foreign_item)
|
||||
fn compute_bounds(ccx: @crate_ctxt,
|
||||
ast_bounds: @~[ast::ty_param_bound]) -> ty::param_bounds {
|
||||
@do vec::flat_map(*ast_bounds) |b| {
|
||||
match b {
|
||||
match *b {
|
||||
ast::bound_send => ~[ty::bound_send],
|
||||
ast::bound_copy => ~[ty::bound_copy],
|
||||
ast::bound_const => ~[ty::bound_const],
|
||||
|
@ -507,7 +507,7 @@ fn rollback_to<V:Copy vid, T:Copy>(
|
||||
vb: &vals_and_bindings<V, T>, len: uint) {
|
||||
|
||||
while vb.bindings.len() != len {
|
||||
let (vid, old_v) = vec::pop(vb.bindings);
|
||||
let (vid, old_v) = vb.bindings.pop();
|
||||
vb.vals.insert(vid.to_uint(), old_v);
|
||||
}
|
||||
}
|
||||
|
@ -1192,7 +1192,7 @@ impl RegionVarBindings {
|
||||
set.insert(*orig_node_idx, ());
|
||||
let mut result = ~[];
|
||||
while !vec::is_empty(stack) {
|
||||
let node_idx = vec::pop(stack);
|
||||
let node_idx = stack.pop();
|
||||
for self.each_edge(graph, node_idx, dir) |edge| {
|
||||
match edge.constraint {
|
||||
ConstrainVarSubVar(from_vid, to_vid) => {
|
||||
|
@ -170,7 +170,7 @@ impl resolve_state {
|
||||
}
|
||||
|
||||
fn resolve_ty_var(vid: TyVid) -> ty::t {
|
||||
if vec::contains(self.v_seen, vid) {
|
||||
if vec::contains(self.v_seen, &vid) {
|
||||
self.err = Some(cyclic_ty(vid));
|
||||
return ty::mk_var(self.infcx.tcx, vid);
|
||||
} else {
|
||||
@ -197,7 +197,7 @@ impl resolve_state {
|
||||
ty::mk_var(tcx, vid)
|
||||
}
|
||||
};
|
||||
vec::pop(self.v_seen);
|
||||
self.v_seen.pop();
|
||||
return t1;
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ fn merge_method_attrs(
|
||||
|
||||
{
|
||||
desc: desc,
|
||||
.. doc
|
||||
..*doc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,8 +228,8 @@ fn maybe_find_pandoc(
|
||||
};
|
||||
|
||||
let pandoc = do vec::find(possible_pandocs) |pandoc| {
|
||||
let output = program_output(pandoc, ~[~"--version"]);
|
||||
debug!("testing pandoc cmd %s: %?", pandoc, output);
|
||||
let output = program_output(*pandoc, ~[~"--version"]);
|
||||
debug!("testing pandoc cmd %s: %?", *pandoc, output);
|
||||
output.status == 0
|
||||
};
|
||||
|
||||
|
@ -165,7 +165,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
|
||||
let paras = do vec::foldl(~[], lines) |paras, line| {
|
||||
let mut res = paras;
|
||||
|
||||
if str::is_whitespace(line) {
|
||||
if str::is_whitespace(*line) {
|
||||
whitespace_lines += 1;
|
||||
} else {
|
||||
if whitespace_lines > 0 {
|
||||
@ -178,9 +178,9 @@ fn paragraphs(s: ~str) -> ~[~str] {
|
||||
whitespace_lines = 0;
|
||||
|
||||
accum = if str::is_empty(accum) {
|
||||
line
|
||||
*line
|
||||
} else {
|
||||
accum + ~"\n" + line
|
||||
accum + ~"\n" + *line
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ impl IndexEntry : cmp::Eq {
|
||||
impl Doc {
|
||||
fn CrateDoc() -> CrateDoc {
|
||||
option::get(&vec::foldl(None, self.pages, |_m, page| {
|
||||
match page {
|
||||
match *page {
|
||||
doc::CratePage(doc) => Some(doc),
|
||||
_ => None
|
||||
}
|
||||
@ -395,7 +395,7 @@ impl ModDoc {
|
||||
|
||||
fn mods() -> ~[ModDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
match *itemtag {
|
||||
ModTag(ModDoc) => Some(ModDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -404,7 +404,7 @@ impl ModDoc {
|
||||
|
||||
fn nmods() -> ~[NmodDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
match *itemtag {
|
||||
NmodTag(nModDoc) => Some(nModDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -413,7 +413,7 @@ impl ModDoc {
|
||||
|
||||
fn fns() -> ~[FnDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
match *itemtag {
|
||||
FnTag(FnDoc) => Some(FnDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -422,7 +422,7 @@ impl ModDoc {
|
||||
|
||||
fn consts() -> ~[ConstDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
match *itemtag {
|
||||
ConstTag(ConstDoc) => Some(ConstDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -431,7 +431,7 @@ impl ModDoc {
|
||||
|
||||
fn enums() -> ~[EnumDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
match *itemtag {
|
||||
EnumTag(EnumDoc) => Some(EnumDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -440,7 +440,7 @@ impl ModDoc {
|
||||
|
||||
fn traits() -> ~[TraitDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
match *itemtag {
|
||||
TraitTag(TraitDoc) => Some(TraitDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -449,7 +449,7 @@ impl ModDoc {
|
||||
|
||||
fn impls() -> ~[ImplDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
match *itemtag {
|
||||
ImplTag(ImplDoc) => Some(ImplDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -458,7 +458,7 @@ impl ModDoc {
|
||||
|
||||
fn types() -> ~[TyDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
match *itemtag {
|
||||
TyTag(TyDoc) => Some(TyDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -467,7 +467,7 @@ impl ModDoc {
|
||||
|
||||
fn structs() -> ~[StructDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match itemtag {
|
||||
match *itemtag {
|
||||
StructTag(StructDoc) => Some(StructDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -490,7 +490,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn mods() -> ~[ModDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
match *page {
|
||||
ItemPage(ModTag(ModDoc)) => Some(ModDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -499,7 +499,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn nmods() -> ~[NmodDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
match *page {
|
||||
ItemPage(NmodTag(nModDoc)) => Some(nModDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -508,7 +508,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn fns() -> ~[FnDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
match *page {
|
||||
ItemPage(FnTag(FnDoc)) => Some(FnDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -517,7 +517,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn consts() -> ~[ConstDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
match *page {
|
||||
ItemPage(ConstTag(ConstDoc)) => Some(ConstDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -526,7 +526,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn enums() -> ~[EnumDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
match *page {
|
||||
ItemPage(EnumTag(EnumDoc)) => Some(EnumDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -535,7 +535,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn traits() -> ~[TraitDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
match *page {
|
||||
ItemPage(TraitTag(TraitDoc)) => Some(TraitDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -544,7 +544,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn impls() -> ~[ImplDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
match *page {
|
||||
ItemPage(ImplTag(ImplDoc)) => Some(ImplDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -553,7 +553,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn types() -> ~[TyDoc] {
|
||||
do vec::filter_map(self) |page| {
|
||||
match page {
|
||||
match *page {
|
||||
ItemPage(TyTag(TyDoc)) => Some(TyDoc),
|
||||
_ => None
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ fn fold_mod(
|
||||
fn strip_mod(doc: doc::ModDoc) -> doc::ModDoc {
|
||||
doc::ModDoc_({
|
||||
items: do vec::filter(doc.items) |item| {
|
||||
match item {
|
||||
match *item {
|
||||
doc::ModTag(_) => false,
|
||||
doc::NmodTag(_) => false,
|
||||
_ => true
|
||||
|
@ -45,7 +45,7 @@ fn fold_mod(fold: fold::Fold<Ctxt>, doc: doc::ModDoc) -> doc::ModDoc {
|
||||
|
||||
if !is_topmod { fold.ctxt.path.push(doc.name()); }
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
if !is_topmod { vec::pop(fold.ctxt.path); }
|
||||
if !is_topmod { fold.ctxt.path.pop(); }
|
||||
|
||||
doc::ModDoc_({
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
@ -56,7 +56,7 @@ fn fold_mod(fold: fold::Fold<Ctxt>, doc: doc::ModDoc) -> doc::ModDoc {
|
||||
fn fold_nmod(fold: fold::Fold<Ctxt>, doc: doc::NmodDoc) -> doc::NmodDoc {
|
||||
fold.ctxt.path.push(doc.name());
|
||||
let doc = fold::default_seq_fold_nmod(fold, doc);
|
||||
vec::pop(fold.ctxt.path);
|
||||
fold.ctxt.path.pop();
|
||||
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
|
@ -177,7 +177,7 @@ fn get_method_sig(
|
||||
node: ast::item_trait(_, _, methods), _
|
||||
}, _) => {
|
||||
match vec::find(methods, |method| {
|
||||
match method {
|
||||
match *method {
|
||||
ast::required(ty_m) => to_str(ty_m.ident) == method_name,
|
||||
ast::provided(m) => to_str(m.ident) == method_name,
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ fn unindent(s: ~str) -> ~str {
|
||||
let ignore_previous_indents =
|
||||
saw_first_line &&
|
||||
!saw_second_line &&
|
||||
!str::is_whitespace(line);
|
||||
!str::is_whitespace(*line);
|
||||
|
||||
let min_indent = if ignore_previous_indents {
|
||||
uint::max_value
|
||||
@ -41,12 +41,12 @@ fn unindent(s: ~str) -> ~str {
|
||||
saw_second_line = true;
|
||||
}
|
||||
|
||||
if str::is_whitespace(line) {
|
||||
if str::is_whitespace(*line) {
|
||||
min_indent
|
||||
} else {
|
||||
saw_first_line = true;
|
||||
let mut spaces = 0;
|
||||
do str::all(line) |char| {
|
||||
do str::all(*line) |char| {
|
||||
// Only comparing against space because I wouldn't
|
||||
// know what to do with mixed whitespace chars
|
||||
if char == ' ' {
|
||||
|
@ -47,7 +47,7 @@ fn shift_push() {
|
||||
let mut v2 = ~[];
|
||||
|
||||
while v1.len() > 0 {
|
||||
v2.push(vec::shift(v1));
|
||||
v2.push(v1.shift());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ fn gen_search_keys(graph: graph, n: uint) -> ~[node_id] {
|
||||
let k = r.gen_uint_range(0u, graph.len());
|
||||
|
||||
if graph[k].len() > 0u && vec::any(graph[k], |i| {
|
||||
i != k as node_id
|
||||
*i != k as node_id
|
||||
}) {
|
||||
map::set_add(keys, k as node_id);
|
||||
}
|
||||
@ -160,8 +160,8 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
||||
}
|
||||
};
|
||||
|
||||
fn is_gray(c: color) -> bool {
|
||||
match c {
|
||||
fn is_gray(c: &color) -> bool {
|
||||
match *c {
|
||||
gray(_) => { true }
|
||||
_ => { false }
|
||||
}
|
||||
@ -183,7 +183,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
||||
let mut color = white;
|
||||
|
||||
do neighbors.each() |k| {
|
||||
if is_gray(colors[*k]) {
|
||||
if is_gray(&colors[*k]) {
|
||||
color = gray(*k);
|
||||
false
|
||||
}
|
||||
@ -314,7 +314,7 @@ fn validate(edges: ~[(node_id, node_id)],
|
||||
}
|
||||
else {
|
||||
while parent != root {
|
||||
if vec::contains(path, parent) {
|
||||
if vec::contains(path, &parent) {
|
||||
status = false;
|
||||
}
|
||||
|
||||
@ -336,8 +336,8 @@ fn validate(edges: ~[(node_id, node_id)],
|
||||
log(info, ~"Verifying tree edges...");
|
||||
|
||||
let status = do tree.alli() |k, parent| {
|
||||
if parent != root && parent != -1i64 {
|
||||
level[parent] == level[k] - 1
|
||||
if *parent != root && *parent != -1i64 {
|
||||
level[*parent] == level[k] - 1
|
||||
}
|
||||
else {
|
||||
true
|
||||
|
@ -27,7 +27,7 @@ fn recv(p: &pipe) -> uint {
|
||||
while vec::is_empty(*state) {
|
||||
cond.wait();
|
||||
}
|
||||
vec::pop(*state)
|
||||
state.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ fn recv(p: &pipe) -> uint {
|
||||
while vec::is_empty(*state) {
|
||||
cond.wait();
|
||||
}
|
||||
vec::pop(*state)
|
||||
state.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
fn compute1() -> float {
|
||||
let v = ~[0f, 1f, 2f, 3f];
|
||||
|
||||
do vec::foldl(0f, v) |x, y| { x + y } - 10f
|
||||
do vec::foldl(0f, v) |x, y| { x + *y } - 10f
|
||||
//~^ ERROR mismatched types: expected `()`
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ fn broken() -> int {
|
||||
y += ~[&mut z]; //~ ERROR illegal borrow
|
||||
x += 1;
|
||||
}
|
||||
vec::foldl(0, y, |v, p| v + *p )
|
||||
vec::foldl(0, y, |v, p| v + **p )
|
||||
}
|
||||
|
||||
fn main() { }
|
@ -2,7 +2,7 @@ fn main() {
|
||||
let v = ~[-1f, 0f, 1f, 2f, 3f];
|
||||
|
||||
// Trailing expressions don't require parentheses:
|
||||
let y = do vec::foldl(0f, v) |x, y| { x + y } + 10f;
|
||||
let y = do vec::foldl(0f, v) |x, y| { x + *y } + 10f;
|
||||
|
||||
assert y == 15f;
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
fn w_semi(v: ~[int]) -> int {
|
||||
// the semicolon causes compiler not to
|
||||
// complain about the ignored return value:
|
||||
do vec::foldl(0, v) |x,y| { x+y };
|
||||
do vec::foldl(0, v) |x,y| { x+*y };
|
||||
-10
|
||||
}
|
||||
|
||||
fn w_paren1(v: ~[int]) -> int {
|
||||
(do vec::foldl(0, v) |x,y| { x+y }) - 10
|
||||
(do vec::foldl(0, v) |x,y| { x+*y }) - 10
|
||||
}
|
||||
|
||||
fn w_paren2(v: ~[int]) -> int {
|
||||
(do vec::foldl(0, v) |x,y| { x+y} - 10)
|
||||
(do vec::foldl(0, v) |x,y| { x+*y} - 10)
|
||||
}
|
||||
|
||||
fn w_ret(v: ~[int]) -> int {
|
||||
return do vec::foldl(0, v) |x,y| { x+y } - 10;
|
||||
return do vec::foldl(0, v) |x,y| { x+*y } - 10;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -8,28 +8,28 @@ fn main() {
|
||||
}
|
||||
|
||||
// Usable at all:
|
||||
let mut any_negative = do vec::any(v) |e| { float::is_negative(e) };
|
||||
let mut any_negative = do vec::any(v) |e| { float::is_negative(*e) };
|
||||
assert any_negative;
|
||||
|
||||
// Higher precedence than assignments:
|
||||
any_negative = do vec::any(v) |e| { float::is_negative(e) };
|
||||
any_negative = do vec::any(v) |e| { float::is_negative(*e) };
|
||||
assert any_negative;
|
||||
|
||||
// Higher precedence than unary operations:
|
||||
let abs_v = do vec::map(v) |e| { float::abs(*e) };
|
||||
assert do vec::all(abs_v) |e| { float::is_nonnegative(e) };
|
||||
assert !do vec::any(abs_v) |e| { float::is_negative(e) };
|
||||
assert do vec::all(abs_v) |e| { float::is_nonnegative(*e) };
|
||||
assert !do vec::any(abs_v) |e| { float::is_negative(*e) };
|
||||
|
||||
// Usable in funny statement-like forms:
|
||||
if !do vec::any(v) |e| { float::is_positive(e) } {
|
||||
if !do vec::any(v) |e| { float::is_positive(*e) } {
|
||||
assert false;
|
||||
}
|
||||
match do vec::all(v) |e| { float::is_negative(e) } {
|
||||
match do vec::all(v) |e| { float::is_negative(*e) } {
|
||||
true => { fail ~"incorrect answer."; }
|
||||
false => { }
|
||||
}
|
||||
match 3 {
|
||||
_ if do vec::any(v) |e| { float::is_negative(e) } => {
|
||||
_ if do vec::any(v) |e| { float::is_negative(*e) } => {
|
||||
}
|
||||
_ => {
|
||||
fail ~"wrong answer.";
|
||||
@ -38,15 +38,15 @@ fn main() {
|
||||
|
||||
|
||||
// Lower precedence than binary operations:
|
||||
let w = do vec::foldl(0f, v) |x, y| { x + y } + 10f;
|
||||
let y = do vec::foldl(0f, v) |x, y| { x + y } + 10f;
|
||||
let z = 10f + do vec::foldl(0f, v) |x, y| { x + y };
|
||||
let w = do vec::foldl(0f, v) |x, y| { x + *y } + 10f;
|
||||
let y = do vec::foldl(0f, v) |x, y| { x + *y } + 10f;
|
||||
let z = 10f + do vec::foldl(0f, v) |x, y| { x + *y };
|
||||
assert w == y;
|
||||
assert y == z;
|
||||
|
||||
// In the tail of a block
|
||||
let w =
|
||||
if true { do vec::any(abs_v) |e| { float::is_nonnegative(e) } }
|
||||
if true { do vec::any(abs_v) |e| { float::is_nonnegative(*e) } }
|
||||
else { false };
|
||||
assert w;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ fn main() {
|
||||
let v =
|
||||
vec::map2(~[1, 2, 3, 4, 5],
|
||||
~[true, false, false, true, true],
|
||||
|i, b| if b { -i } else { i } );
|
||||
|i, b| if *b { -(*i) } else { *i } );
|
||||
log(error, v);
|
||||
assert (v == ~[-1, 2, 3, -4, -5]);
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ fn ret_deep() -> ~str {
|
||||
fn main() {
|
||||
let mut last = 0;
|
||||
for vec::all(~[1, 2, 3, 4, 5, 6, 7]) |e| {
|
||||
last = e;
|
||||
if e == 5 { break; }
|
||||
if e % 2 == 1 { loop; }
|
||||
assert e % 2 == 0;
|
||||
last = *e;
|
||||
if *e == 5 { break; }
|
||||
if *e % 2 == 1 { loop; }
|
||||
assert *e % 2 == 0;
|
||||
};
|
||||
assert last == 5;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user