new borrow checker (mass squash)
This commit is contained in:
parent
b5a7e8b353
commit
a896440ca1
172 changed files with 6475 additions and 4303 deletions
|
|
@ -419,26 +419,26 @@ pub struct RWReadMode<'self, T> {
|
|||
|
||||
pub impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
|
||||
/// Access the pre-downgrade RWARC in write mode.
|
||||
fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
|
||||
fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
|
||||
match *self {
|
||||
RWWriteMode {
|
||||
data: ref data,
|
||||
data: &ref mut data,
|
||||
token: ref token,
|
||||
poison: _
|
||||
} => {
|
||||
do token.write {
|
||||
blk(&mut **data)
|
||||
blk(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Access the pre-downgrade RWARC in write mode with a condvar.
|
||||
fn write_cond<'x, 'c, U>(&self,
|
||||
fn write_cond<'x, 'c, U>(&mut self,
|
||||
blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
|
||||
-> U {
|
||||
match *self {
|
||||
RWWriteMode {
|
||||
data: ref data,
|
||||
data: &ref mut data,
|
||||
token: ref token,
|
||||
poison: ref poison
|
||||
} => {
|
||||
|
|
@ -449,7 +449,7 @@ pub impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
|
|||
failed: &mut *poison.failed,
|
||||
cond: cond
|
||||
};
|
||||
blk(&mut **data, &cvar)
|
||||
blk(data, &cvar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,16 +215,16 @@ pub struct Bitv {
|
|||
nbits: uint
|
||||
}
|
||||
|
||||
priv impl Bitv {
|
||||
fn die() -> ! {
|
||||
fail!(~"Tried to do operation on bit vectors with different sizes");
|
||||
}
|
||||
|
||||
fn die(&self) -> ! {
|
||||
fail!(~"Tried to do operation on bit vectors with different sizes");
|
||||
}
|
||||
priv impl Bitv {
|
||||
|
||||
#[inline(always)]
|
||||
fn do_op(&mut self, op: Op, other: &Bitv) -> bool {
|
||||
if self.nbits != other.nbits {
|
||||
self.die();
|
||||
die();
|
||||
}
|
||||
match self.rep {
|
||||
Small(ref mut s) => match other.rep {
|
||||
|
|
@ -234,10 +234,10 @@ priv impl Bitv {
|
|||
Assign => s.become(*s1, self.nbits),
|
||||
Difference => s.difference(*s1, self.nbits)
|
||||
},
|
||||
Big(_) => self.die()
|
||||
Big(_) => die()
|
||||
},
|
||||
Big(ref mut s) => match other.rep {
|
||||
Small(_) => self.die(),
|
||||
Small(_) => die(),
|
||||
Big(ref s1) => match op {
|
||||
Union => s.union(*s1, self.nbits),
|
||||
Intersect => s.intersect(*s1, self.nbits),
|
||||
|
|
|
|||
|
|
@ -885,8 +885,8 @@ impl io::Reader for TcpSocketBuf {
|
|||
let ncopy = uint::min(nbuffered, needed);
|
||||
let dst = ptr::mut_offset(
|
||||
vec::raw::to_mut_ptr(buf), count);
|
||||
let src = ptr::const_offset(
|
||||
vec::raw::to_const_ptr(self.data.buf),
|
||||
let src = ptr::offset(
|
||||
vec::raw::to_ptr(self.data.buf),
|
||||
self.data.buf_off);
|
||||
ptr::copy_memory(dst, src, ncopy);
|
||||
self.data.buf_off += ncopy;
|
||||
|
|
@ -969,7 +969,7 @@ impl io::Reader for TcpSocketBuf {
|
|||
|
||||
/// Implementation of `io::Reader` trait for a buffered `net::tcp::TcpSocket`
|
||||
impl io::Writer for TcpSocketBuf {
|
||||
pub fn write(&self, data: &const [u8]) {
|
||||
pub fn write(&self, data: &[u8]) {
|
||||
unsafe {
|
||||
let socket_data_ptr: *TcpSocketData =
|
||||
&(*((*(self.data)).sock).socket_data);
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@ use core::hashmap::{HashMap, HashSet};
|
|||
use core::trie::{TrieMap, TrieSet};
|
||||
use deque::Deque;
|
||||
use dlist::DList;
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
#[cfg(stage3)]
|
||||
use treemap::{TreeMap, TreeSet};
|
||||
|
||||
pub trait Encoder {
|
||||
|
|
@ -730,9 +727,6 @@ impl<D: Decoder> Decodable<D> for TrieSet {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
#[cfg(stage3)]
|
||||
impl<
|
||||
E: Encoder,
|
||||
K: Encodable<E> + Eq + TotalOrd,
|
||||
|
|
@ -750,9 +744,6 @@ impl<
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
#[cfg(stage3)]
|
||||
impl<
|
||||
D: Decoder,
|
||||
K: Decodable<D> + Eq + TotalOrd,
|
||||
|
|
@ -771,9 +762,6 @@ impl<
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
#[cfg(stage3)]
|
||||
impl<
|
||||
S: Encoder,
|
||||
T: Encodable<S> + Eq + TotalOrd
|
||||
|
|
@ -789,9 +777,6 @@ impl<
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
#[cfg(stage3)]
|
||||
impl<
|
||||
D: Decoder,
|
||||
T: Decodable<D> + Eq + TotalOrd
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ pub fn merge_sort<T:Copy>(v: &const [T], le: Le<T>) -> ~[T] {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn part<T>(arr: &mut [T], left: uint,
|
||||
right: uint, pivot: uint, compare_func: Le<T>) -> uint {
|
||||
arr[pivot] <-> arr[right];
|
||||
|
|
@ -79,6 +80,23 @@ fn part<T>(arr: &mut [T], left: uint,
|
|||
return storage_index;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
fn part<T>(arr: &mut [T], left: uint,
|
||||
right: uint, pivot: uint, compare_func: Le<T>) -> uint {
|
||||
arr[pivot] <-> arr[right];
|
||||
let mut storage_index: uint = left;
|
||||
let mut i: uint = left;
|
||||
while i < right {
|
||||
if compare_func(&arr[i], &arr[right]) {
|
||||
arr[i] <-> arr[storage_index];
|
||||
storage_index += 1;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
arr[storage_index] <-> arr[right];
|
||||
return storage_index;
|
||||
}
|
||||
|
||||
fn qsort<T>(arr: &mut [T], left: uint,
|
||||
right: uint, compare_func: Le<T>) {
|
||||
if right > left {
|
||||
|
|
@ -162,7 +180,8 @@ fn qsort3<T:Copy + Ord + Eq>(arr: &mut [T], left: int, right: int) {
|
|||
*/
|
||||
pub fn quick_sort3<T:Copy + Ord + Eq>(arr: &mut [T]) {
|
||||
if arr.len() <= 1 { return; }
|
||||
qsort3(arr, 0, (arr.len() - 1) as int);
|
||||
let len = arr.len() - 1; // FIXME(#5074) nested calls
|
||||
qsort3(arr, 0, (len - 1) as int);
|
||||
}
|
||||
|
||||
pub trait Sort {
|
||||
|
|
@ -195,15 +214,20 @@ pub fn tim_sort<T:Copy + Ord>(array: &mut [T]) {
|
|||
let mut idx = 0;
|
||||
let mut remaining = size;
|
||||
loop {
|
||||
let arr = vec::mut_slice(array, idx, size);
|
||||
let mut run_len: uint = count_run_ascending(arr);
|
||||
let run_len: uint = {
|
||||
// This scope contains the slice `arr` here:
|
||||
let arr = vec::mut_slice(array, idx, size);
|
||||
let mut run_len: uint = count_run_ascending(arr);
|
||||
|
||||
if run_len < min_run {
|
||||
let force = if remaining <= min_run {remaining} else {min_run};
|
||||
let slice = vec::mut_slice(arr, 0, force);
|
||||
binarysort(slice, run_len);
|
||||
run_len = force;
|
||||
}
|
||||
if run_len < min_run {
|
||||
let force = if remaining <= min_run {remaining} else {min_run};
|
||||
let slice = vec::mut_slice(arr, 0, force);
|
||||
binarysort(slice, run_len);
|
||||
run_len = force;
|
||||
}
|
||||
|
||||
run_len
|
||||
};
|
||||
|
||||
ms.push_run(idx, run_len);
|
||||
ms.merge_collapse(array);
|
||||
|
|
@ -250,7 +274,7 @@ fn binarysort<T:Copy + Ord>(array: &mut [T], start: uint) {
|
|||
fn reverse_slice<T>(v: &mut [T], start: uint, end:uint) {
|
||||
let mut i = start;
|
||||
while i < end / 2 {
|
||||
util::swap(&mut v[i], &mut v[end - i - 1]);
|
||||
v[i] <-> v[end - i - 1];
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -433,14 +457,17 @@ impl<T:Copy + Ord> MergeState<T> {
|
|||
self.runs[n+1].len = self.runs[n+2].len;
|
||||
}
|
||||
|
||||
let slice = vec::mut_slice(array, b1, b1+l1);
|
||||
let k = gallop_right(&const array[b2], slice, 0);
|
||||
let k = { // constrain lifetime of slice below
|
||||
let slice = vec::mut_slice(array, b1, b1+l1);
|
||||
gallop_right(&const array[b2], slice, 0)
|
||||
};
|
||||
b1 += k;
|
||||
l1 -= k;
|
||||
if l1 != 0 {
|
||||
let slice = vec::mut_slice(array, b2, b2+l2);
|
||||
let l2 = gallop_left(
|
||||
&const array[b1+l1-1],slice,l2-1);
|
||||
let l2 = { // constrain lifetime of slice below
|
||||
let slice = vec::mut_slice(array, b2, b2+l2);
|
||||
gallop_left(&const array[b1+l1-1],slice,l2-1)
|
||||
};
|
||||
if l2 > 0 {
|
||||
if l1 <= l2 {
|
||||
self.merge_lo(array, b1, l1, b2, l2);
|
||||
|
|
@ -621,9 +648,11 @@ impl<T:Copy + Ord> MergeState<T> {
|
|||
loop {
|
||||
assert!(len2 > 1 && len1 != 0);
|
||||
|
||||
let tmp_view = vec::mut_slice(array, base1, base1+len1);
|
||||
count1 = len1 - gallop_right(
|
||||
&const tmp[c2], tmp_view, len1-1);
|
||||
{ // constrain scope of tmp_view:
|
||||
let tmp_view = vec::mut_slice (array, base1, base1+len1);
|
||||
count1 = len1 - gallop_right(
|
||||
&const tmp[c2], tmp_view, len1-1);
|
||||
}
|
||||
|
||||
if count1 != 0 {
|
||||
dest -= count1; c1 -= count1; len1 -= count1;
|
||||
|
|
@ -636,12 +665,11 @@ impl<T:Copy + Ord> MergeState<T> {
|
|||
if len2 == 1 { break_outer = true; break; }
|
||||
|
||||
let count2;
|
||||
{
|
||||
{ // constrain scope of tmp_view
|
||||
let tmp_view = vec::mut_slice(tmp, 0, len2);
|
||||
count2 = len2 - gallop_left(&const array[c1],
|
||||
tmp_view,
|
||||
len2-1);
|
||||
// Make tmp_view go out of scope to appease borrowck.
|
||||
}
|
||||
|
||||
if count2 != 0 {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ pub mod rope;
|
|||
pub mod smallintmap;
|
||||
pub mod sort;
|
||||
pub mod dlist;
|
||||
#[cfg(not(stage0))]
|
||||
pub mod treemap;
|
||||
|
||||
// And ... other stuff
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue