Fix the signature on vec::view.

Due to limitations in region inference, this has the effect of making vec::view pretty much entirely unusable.
This commit is contained in:
Eric Holk 2012-07-12 10:47:37 -07:00
parent 1a276dba52
commit aba665da32
6 changed files with 19 additions and 11 deletions

View file

@ -258,13 +258,13 @@ pure fn slice<T: copy>(v: &[const T], start: uint, end: uint) -> ~[T] {
assert (end <= len(v));
let mut result = ~[];
unchecked {
push_all(result, view(v, start, end));
for uint::range(start, end) |i| { vec::push(result, v[i]) }
}
ret result;
}
#[doc = "Return a slice that points into another slice."]
pure fn view<T>(v: &[const T], start: uint, end: uint) -> &a.[T] {
pure fn view<T>(v: &a.[T], start: uint, end: uint) -> &a.[T] {
assert (start <= end);
assert (end <= len(v));
do unpack_slice(v) |p, _len| {

View file

@ -123,7 +123,8 @@ fn tagged_docs(d: doc, tg: uint, it: fn(doc)) {
fn doc_data(d: doc) -> ~[u8] { vec::slice::<u8>(*d.data, d.start, d.end) }
fn with_doc_data<T>(d: doc, f: fn(x: &[u8]) -> T) -> T {
ret f(vec::view::<u8>(*d.data, d.start, d.end));
// FIXME (#2880): use vec::view once the region inferencer can handle it.
ret f(vec::slice::<u8>(*d.data, d.start, d.end));
}
fn doc_as_str(d: doc) -> str { ret str::from_bytes(doc_data(d)); }

View file

@ -144,7 +144,8 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path {
let mut path = ~[];
for uint::range(start_idx, len1 - 1u) |_i| { vec::push(path, ".."); };
vec::push_all(path, vec::view(split2, start_idx, len2 - 1u));
// FIXME (#2880): use view here.
vec::push_all(path, vec::slice(split2, start_idx, len2 - 1u));
if check vec::is_not_empty(path) {
ret path::connect_many(path);

View file

@ -73,7 +73,8 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn@(x:&[u8]) -> bool, hash: uint) ->
let belt = tag_index_buckets_bucket_elt;
do ebml::tagged_docs(bucket, belt) |elt| {
let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint;
if eq_fn(vec::view::<u8>(*elt.data, elt.start + 4u, elt.end)) {
// FIXME (#2880): use view here.
if eq_fn(vec::slice::<u8>(*elt.data, elt.start + 4u, elt.end)) {
vec::push(result, ebml::doc_at(d.data, pos).doc);
}
};

View file

@ -114,7 +114,8 @@ fn expand_nested_bindings(m: match, col: uint, val: ValueRef) -> match {
let pats = vec::append(
vec::slice(br.pats, 0u, col),
vec::append(~[inner],
vec::view(br.pats, col + 1u, br.pats.len())));
// FIXME (#2880): use view here.
vec::slice(br.pats, col + 1u, br.pats.len())));
vec::push(result,
@{pats: pats,
bound: vec::append(
@ -137,8 +138,10 @@ fn enter_match(dm: def_map, m: match, col: uint, val: ValueRef,
alt e(br.pats[col]) {
some(sub) {
let pats = vec::append(
vec::append(sub, vec::view(br.pats, 0u, col)),
vec::view(br.pats, col + 1u, br.pats.len()));
// FIXME (#2880): use view here.
vec::append(sub, vec::slice(br.pats, 0u, col)),
// FIXME (#2880): use view here.
vec::slice(br.pats, col + 1u, br.pats.len()));
let self = br.pats[col];
let bound = alt self.node {
ast::pat_ident(name, none) if !pat_is_variant(dm, self) {
@ -427,7 +430,8 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef],
} else { m };
let vals_left = vec::append(vec::slice(vals, 0u, col),
vec::view(vals, col + 1u, vals.len()));
// FIXME (#2880): use view here.
vec::slice(vals, col + 1u, vals.len()));
let ccx = bcx.fcx.ccx;
let mut pat_id = 0;
for vec::each(m) |br| {

View file

@ -313,7 +313,8 @@ fn revoke_clean(cx: block, val: ValueRef) {
})) |i| {
info.cleanups =
vec::append(vec::slice(info.cleanups, 0u, i),
vec::view(info.cleanups,
// FIXME (#2880): use view here.
vec::slice(info.cleanups,
i + 1u,
info.cleanups.len()));
scope_clean_changed(info);