Skip to content

Commit 8ee79c7

Browse files
committed
new region inference, seperate infer into modules, improve error msgs
Fixes #2806 Fixes #3197 Fixes #3138
1 parent 3b09c3d commit 8ee79c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3868
-2565
lines changed

src/libcore/dvec.rs

+27-8
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ priv impl<A> DVec<A> {
9090
}
9191

9292
#[inline(always)]
93-
fn borrow<B>(f: fn(-~[mut A]) -> B) -> B {
93+
fn check_out<B>(f: fn(-~[mut A]) -> B) -> B {
9494
unsafe {
9595
let mut data = unsafe::reinterpret_cast(null::<()>());
9696
data <-> self.data;
@@ -124,13 +124,13 @@ impl<A> DVec<A> {
124124
*/
125125
#[inline(always)]
126126
fn swap(f: fn(-~[mut A]) -> ~[mut A]) {
127-
self.borrow(|v| self.give_back(f(v)))
127+
self.check_out(|v| self.give_back(f(v)))
128128
}
129129

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

147147
/// Remove and return the last element
148148
fn pop() -> A {
149-
do self.borrow |v| {
149+
do self.check_out |v| {
150150
let mut v <- v;
151151
let result = vec::pop(v);
152152
self.give_back(v);
@@ -176,18 +176,37 @@ impl<A> DVec<A> {
176176
177177
/// Remove and return the first element
178178
fn shift() -> A {
179-
do self.borrow |v| {
179+
do self.check_out |v| {
180180
let mut v = vec::from_mut(v);
181181
let result = vec::shift(v);
182182
self.give_back(vec::to_mut(v));
183183
result
184184
}
185185
}
186186
187-
// Reverse the elements in the list, in place
187+
/// Reverse the elements in the list, in place
188188
fn reverse() {
189-
do self.borrow |v| {
189+
do self.check_out |v| {
190190
vec::reverse(v);
191+
self.give_back(v);
192+
}
193+
}
194+
195+
/// Gives access to the vector as a slice with immutable contents
196+
fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
197+
do self.check_out |v| {
198+
let result = op(v);
199+
self.give_back(v);
200+
result
201+
}
202+
}
203+
204+
/// Gives access to the vector as a slice with mutable contents
205+
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
206+
do self.check_out |v| {
207+
let result = op(v);
208+
self.give_back(v);
209+
result
191210
}
192211
}
193212
}
@@ -249,7 +268,7 @@ impl<A: copy> DVec<A> {
249268
*/
250269
pure fn get() -> ~[A] {
251270
unchecked {
252-
do self.borrow |v| {
271+
do self.check_out |v| {
253272
let w = vec::from_mut(copy v);
254273
self.give_back(v);
255274
w

src/libcore/task.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,9 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
11871187
};
11881188
if result {
11891189
// Unwinding function in case any ancestral enlisting fails
1190-
let bail = |tg| { leave_taskgroup(tg, child, false) };
1190+
let bail = |tg: TaskGroupInner| {
1191+
leave_taskgroup(tg, child, false)
1192+
};
11911193
// Attempt to join every ancestor group.
11921194
result =
11931195
for each_ancestor(ancestors, some(bail)) |ancestor_tg| {

src/libstd/cell.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ impl<T> Cell<T> {
4141
}
4242

4343
// Calls a closure with a reference to the value.
44-
fn with_ref(f: fn(v: &T)) {
45-
let val = move self.take();
46-
f(&val);
47-
self.put_back(move val);
44+
fn with_ref<R>(op: fn(v: &T) -> R) -> R {
45+
let v = self.take();
46+
let r = op(&v);
47+
self.put_back(v);
48+
return move r;
4849
}
4950
}
5051

0 commit comments

Comments
 (0)