Skip to content

Commit dc00ff2

Browse files
committed
librustc: Make || lambdas not infer to procs
1 parent 17bf45d commit dc00ff2

Some content is hidden

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

66 files changed

+153
-139
lines changed

doc/tutorial-tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn print_message() { println("I am running in a different task!"); }
7676
spawn(print_message);
7777
7878
// Print something more profound in a different task using a lambda expression
79-
spawn( || println("I am also running in a different task!") );
79+
spawn(proc() println("I am also running in a different task!") );
8080
8181
// The canonical way to spawn is using `do` notation
8282
do spawn {
@@ -278,7 +278,7 @@ fn fib(n: u64) -> u64 {
278278
12586269025
279279
}
280280
281-
let mut delayed_fib = extra::future::Future::spawn (|| fib(50) );
281+
let mut delayed_fib = extra::future::Future::spawn(proc() fib(50));
282282
make_a_sandwich();
283283
println!("fib(50) = {:?}", delayed_fib.get())
284284
~~~

src/compiletest/compiletest.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,15 @@ pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
333333
let config = Cell::new((*config).clone());
334334
// FIXME (#9639): This needs to handle non-utf8 paths
335335
let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
336-
test::DynTestFn(|| { runtest::run(config.take(), testfile.take()) })
336+
test::DynTestFn(proc() { runtest::run(config.take(), testfile.take()) })
337337
}
338338

339339
pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::TestFn {
340340
use std::cell::Cell;
341341
let config = Cell::new((*config).clone());
342342
// FIXME (#9639): This needs to handle non-utf8 paths
343343
let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
344-
test::DynMetricFn(|mm| { runtest::run_metrics(config.take(), testfile.take(), mm) })
344+
test::DynMetricFn(proc(mm) {
345+
runtest::run_metrics(config.take(), testfile.take(), mm)
346+
})
345347
}

src/libextra/future.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ mod test {
179179
180180
#[test]
181181
fn test_from_fn() {
182-
let mut f = Future::from_fn(|| ~"brail");
182+
let mut f = Future::from_fn(proc() ~"brail");
183183
assert_eq!(f.get(), ~"brail");
184184
}
185185
@@ -203,20 +203,20 @@ mod test {
203203
204204
#[test]
205205
fn test_spawn() {
206-
let mut f = Future::spawn(|| ~"bale");
206+
let mut f = Future::spawn(proc() ~"bale");
207207
assert_eq!(f.get(), ~"bale");
208208
}
209209
210210
#[test]
211211
fn test_spawn_with() {
212-
let mut f = Future::spawn_with(~"gale", |s| { s });
212+
let mut f = Future::spawn_with(~"gale", proc(s) { s });
213213
assert_eq!(f.get(), ~"gale");
214214
}
215215
216216
#[test]
217217
#[should_fail]
218218
fn test_futurefail() {
219-
let mut f = Future::spawn(|| fail!());
219+
let mut f = Future::spawn(proc() fail!());
220220
let _x: ~str = f.get();
221221
}
222222

src/libextra/task_pool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<T> TaskPool<T> {
5757
let (port, chan) = comm::stream::<Msg<T>>();
5858
let init_fn = init_fn_factory();
5959

60-
let task_body: proc() = || {
60+
let task_body: proc() = proc() {
6161
let local_data = init_fn(i);
6262
loop {
6363
match port.recv() {
@@ -98,11 +98,11 @@ impl<T> TaskPool<T> {
9898
#[test]
9999
fn test_task_pool() {
100100
let f: || -> proc(uint) -> uint = || {
101-
let g: proc(uint) -> uint = |i| i;
101+
let g: proc(uint) -> uint = proc(i) i;
102102
g
103103
};
104104
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
105105
8.times(|| {
106-
pool.execute(|i| println!("Hello from thread {}!", *i));
106+
pool.execute(proc(i) println!("Hello from thread {}!", *i));
107107
})
108108
}

src/libextra/test.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ pub fn run_test(force_ignore: bool,
905905
return;
906906
}
907907
DynTestFn(f) => run_test_inner(desc, monitor_ch, f),
908-
StaticTestFn(f) => run_test_inner(desc, monitor_ch, || f())
908+
StaticTestFn(f) => run_test_inner(desc, monitor_ch, proc() f())
909909
}
910910
}
911911

@@ -1202,7 +1202,7 @@ mod tests {
12021202
ignore: true,
12031203
should_fail: false
12041204
},
1205-
testfn: DynTestFn(|| f()),
1205+
testfn: DynTestFn(proc() f()),
12061206
};
12071207
let (p, ch) = stream();
12081208
let ch = SharedChan::new(ch);
@@ -1220,7 +1220,7 @@ mod tests {
12201220
ignore: true,
12211221
should_fail: false
12221222
},
1223-
testfn: DynTestFn(|| f()),
1223+
testfn: DynTestFn(proc() f()),
12241224
};
12251225
let (p, ch) = stream();
12261226
let ch = SharedChan::new(ch);
@@ -1238,7 +1238,7 @@ mod tests {
12381238
ignore: false,
12391239
should_fail: true
12401240
},
1241-
testfn: DynTestFn(|| f()),
1241+
testfn: DynTestFn(proc() f()),
12421242
};
12431243
let (p, ch) = stream();
12441244
let ch = SharedChan::new(ch);
@@ -1256,7 +1256,7 @@ mod tests {
12561256
ignore: false,
12571257
should_fail: true
12581258
},
1259-
testfn: DynTestFn(|| f()),
1259+
testfn: DynTestFn(proc() f()),
12601260
};
12611261
let (p, ch) = stream();
12621262
let ch = SharedChan::new(ch);
@@ -1311,15 +1311,15 @@ mod tests {
13111311
ignore: true,
13121312
should_fail: false,
13131313
},
1314-
testfn: DynTestFn(|| {}),
1314+
testfn: DynTestFn(proc() {}),
13151315
},
13161316
TestDescAndFn {
13171317
desc: TestDesc {
13181318
name: StaticTestName("2"),
13191319
ignore: false,
13201320
should_fail: false
13211321
},
1322-
testfn: DynTestFn(|| {}),
1322+
testfn: DynTestFn(proc() {}),
13231323
},
13241324
];
13251325
let filtered = filter_tests(&opts, tests);

src/librustc/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub fn monitor(f: proc(@diagnostic::Emitter)) {
346346
task_builder.opts.stack_size = Some(STACK_SIZE);
347347
}
348348

349-
match task_builder.try(|| {
349+
match task_builder.try(proc() {
350350
let ch = ch_capture.clone();
351351
// The 'diagnostics emitter'. Every error, warning, etc. should
352352
// go through this function.
@@ -404,6 +404,6 @@ pub fn main() {
404404

405405
pub fn main_args(args: &[~str]) -> int {
406406
let owned_args = args.to_owned();
407-
monitor(|demitter| run_compiler(owned_args, demitter));
407+
monitor(proc(demitter) run_compiler(owned_args, demitter));
408408
0
409409
}

src/librustc/middle/typeck/check/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,8 +2905,13 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
29052905
_match::check_match(fcx, expr, discrim, *arms);
29062906
}
29072907
ast::ExprFnBlock(ref decl, ref body) => {
2908-
check_expr_fn(fcx, expr, None,
2909-
decl, body, Vanilla, expected);
2908+
check_expr_fn(fcx,
2909+
expr,
2910+
Some(ast::BorrowedSigil),
2911+
decl,
2912+
body,
2913+
Vanilla,
2914+
expected);
29102915
}
29112916
ast::ExprProc(ref decl, ref body) => {
29122917
check_expr_fn(fcx,

src/librustdoc/html/render.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,9 @@ impl Context {
711711
let mut task = task::task();
712712
task.unlinked(); // we kill things manually
713713
task.name(format!("worker{}", i));
714-
task.spawn_with(cache.clone(),
715-
|cache| worker(cache, &port, &chan, &prog_chan));
714+
task.spawn_with(cache.clone(), proc(cache) {
715+
worker(cache, &port, &chan, &prog_chan)
716+
});
716717

717718
fn worker(cache: RWArc<Cache>,
718719
port: &SharedPort<Work>,

src/librustpkg/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl CtxMethods for BuildContext {
474474
let psp = package_script_path.clone();
475475
let ws = workspace.clone();
476476
let pid = pkgid.clone();
477-
prep.exec(|exec| {
477+
prep.exec(proc(exec) {
478478
let mut pscript = PkgScript::parse(subsysroot.clone(),
479479
psp.clone(),
480480
&ws,
@@ -636,7 +636,7 @@ impl CtxMethods for BuildContext {
636636
let sub_target_ex = target_exec.clone();
637637
let sub_target_lib = target_lib.clone();
638638
let sub_build_inputs = build_inputs.to_owned();
639-
prep.exec(|exe_thing| {
639+
prep.exec(proc(exe_thing) {
640640
let mut outputs = ~[];
641641
// Declare all the *inputs* to the declared input too, as inputs
642642
for executable in subex.iter() {

src/librustpkg/package_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl PkgSrc {
412412
let sub_deps = deps.clone();
413413
let inputs = inputs_to_discover.map(|&(ref k, ref p)|
414414
(k.clone(), p.as_str().unwrap().to_owned()));
415-
prep.exec(|exec| {
415+
prep.exec(proc(exec) {
416416
for &(ref kind, ref p) in inputs.iter() {
417417
let pth = Path::new(p.clone());
418418
exec.discover_input(*kind, *p, if *kind == ~"file" {

0 commit comments

Comments
 (0)