Skip to content

Commit

Permalink
new region inference, seperate infer into modules, improve error msgs
Browse files Browse the repository at this point in the history
Fixes #2806
Fixes #3197
Fixes #3138
  • Loading branch information
nikomatsakis committed Aug 21, 2012
1 parent 3b09c3d commit 8ee79c7
Show file tree
Hide file tree
Showing 50 changed files with 3,868 additions and 2,565 deletions.
35 changes: 27 additions & 8 deletions src/libcore/dvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ priv impl<A> DVec<A> {
}

#[inline(always)]
fn borrow<B>(f: fn(-~[mut A]) -> B) -> B {
fn check_out<B>(f: fn(-~[mut A]) -> B) -> B {
unsafe {
let mut data = unsafe::reinterpret_cast(null::<()>());
data <-> self.data;
Expand Down Expand Up @@ -124,13 +124,13 @@ impl<A> DVec<A> {
*/
#[inline(always)]
fn swap(f: fn(-~[mut A]) -> ~[mut A]) {
self.borrow(|v| self.give_back(f(v)))
self.check_out(|v| self.give_back(f(v)))
}

/// Returns the number of elements currently in the dvec
pure fn len() -> uint {
unchecked {
do self.borrow |v| {
do self.check_out |v| {
let l = v.len();
self.give_back(v);
l
Expand All @@ -146,7 +146,7 @@ impl<A> DVec<A> {

/// Remove and return the last element
fn pop() -> A {
do self.borrow |v| {
do self.check_out |v| {
let mut v <- v;
let result = vec::pop(v);
self.give_back(v);
Expand Down Expand Up @@ -176,18 +176,37 @@ impl<A> DVec<A> {
/// Remove and return the first element
fn shift() -> A {
do self.borrow |v| {
do self.check_out |v| {
let mut v = vec::from_mut(v);
let result = vec::shift(v);
self.give_back(vec::to_mut(v));
result
}
}
// Reverse the elements in the list, in place
/// Reverse the elements in the list, in place
fn reverse() {
do self.borrow |v| {
do self.check_out |v| {
vec::reverse(v);
self.give_back(v);
}
}
/// Gives access to the vector as a slice with immutable contents
fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
do self.check_out |v| {
let result = op(v);
self.give_back(v);
result
}
}
/// Gives access to the vector as a slice with mutable contents
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
do self.check_out |v| {
let result = op(v);
self.give_back(v);
result
}
}
}
Expand Down Expand Up @@ -249,7 +268,7 @@ impl<A: copy> DVec<A> {
*/
pure fn get() -> ~[A] {
unchecked {
do self.borrow |v| {
do self.check_out |v| {
let w = vec::from_mut(copy v);
self.give_back(v);
w
Expand Down
4 changes: 3 additions & 1 deletion src/libcore/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,9 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
};
if result {
// Unwinding function in case any ancestral enlisting fails
let bail = |tg| { leave_taskgroup(tg, child, false) };
let bail = |tg: TaskGroupInner| {
leave_taskgroup(tg, child, false)
};
// Attempt to join every ancestor group.
result =
for each_ancestor(ancestors, some(bail)) |ancestor_tg| {
Expand Down
9 changes: 5 additions & 4 deletions src/libstd/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ impl<T> Cell<T> {
}

// Calls a closure with a reference to the value.
fn with_ref(f: fn(v: &T)) {
let val = move self.take();
f(&val);
self.put_back(move val);
fn with_ref<R>(op: fn(v: &T) -> R) -> R {
let v = self.take();
let r = op(&v);
self.put_back(v);
return move r;
}
}

Expand Down
Loading

0 comments on commit 8ee79c7

Please sign in to comment.