Skip to content

Commit 749ee53

Browse files
committed
librustc: Make || lambdas not infer to procs
1 parent 38efa17 commit 749ee53

Some content is hidden

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

64 files changed

+139
-126
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ mod test {
161161
162162
#[test]
163163
fn test_from_fn() {
164-
let mut f = Future::from_fn(|| ~"brail");
164+
let mut f = Future::from_fn(proc() ~"brail");
165165
assert_eq!(f.get(), ~"brail");
166166
}
167167
@@ -185,14 +185,14 @@ mod test {
185185
186186
#[test]
187187
fn test_spawn() {
188-
let mut f = Future::spawn(|| ~"bale");
188+
let mut f = Future::spawn(proc() ~"bale");
189189
assert_eq!(f.get(), ~"bale");
190190
}
191191
192192
#[test]
193193
#[should_fail]
194194
fn test_futurefail() {
195-
let mut f = Future::spawn(|| fail!());
195+
let mut f = Future::spawn(proc() fail!());
196196
let _x: ~str = f.get();
197197
}
198198

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
@@ -912,7 +912,7 @@ pub fn run_test(force_ignore: bool,
912912
return;
913913
}
914914
DynTestFn(f) => run_test_inner(desc, monitor_ch, f),
915-
StaticTestFn(f) => run_test_inner(desc, monitor_ch, || f())
915+
StaticTestFn(f) => run_test_inner(desc, monitor_ch, proc() f())
916916
}
917917
}
918918

@@ -1209,7 +1209,7 @@ mod tests {
12091209
ignore: true,
12101210
should_fail: false
12111211
},
1212-
testfn: DynTestFn(|| f()),
1212+
testfn: DynTestFn(proc() f()),
12131213
};
12141214
let (p, ch) = stream();
12151215
let ch = SharedChan::new(ch);
@@ -1227,7 +1227,7 @@ mod tests {
12271227
ignore: true,
12281228
should_fail: false
12291229
},
1230-
testfn: DynTestFn(|| f()),
1230+
testfn: DynTestFn(proc() f()),
12311231
};
12321232
let (p, ch) = stream();
12331233
let ch = SharedChan::new(ch);
@@ -1245,7 +1245,7 @@ mod tests {
12451245
ignore: false,
12461246
should_fail: true
12471247
},
1248-
testfn: DynTestFn(|| f()),
1248+
testfn: DynTestFn(proc() f()),
12491249
};
12501250
let (p, ch) = stream();
12511251
let ch = SharedChan::new(ch);
@@ -1263,7 +1263,7 @@ mod tests {
12631263
ignore: false,
12641264
should_fail: true
12651265
},
1266-
testfn: DynTestFn(|| f()),
1266+
testfn: DynTestFn(proc() f()),
12671267
};
12681268
let (p, ch) = stream();
12691269
let ch = SharedChan::new(ch);
@@ -1318,15 +1318,15 @@ mod tests {
13181318
ignore: true,
13191319
should_fail: false,
13201320
},
1321-
testfn: DynTestFn(|| {}),
1321+
testfn: DynTestFn(proc() {}),
13221322
},
13231323
TestDescAndFn {
13241324
desc: TestDesc {
13251325
name: StaticTestName("2"),
13261326
ignore: false,
13271327
should_fail: false
13281328
},
1329-
testfn: DynTestFn(|| {}),
1329+
testfn: DynTestFn(proc() {}),
13301330
},
13311331
];
13321332
let filtered = filter_tests(&opts, tests);

src/librustc/lib.rs

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

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

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

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/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" {

src/librustuv/net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ mod test {
10921092
let handle2 = Cell::new(sched2.make_handle());
10931093
let tasksFriendHandle = Cell::new(sched2.make_handle());
10941094
1095-
let on_exit: proc(UnwindResult) = |exit_status| {
1095+
let on_exit: proc(UnwindResult) = proc(exit_status) {
10961096
handle1.take().send(Shutdown);
10971097
handle2.take().send(Shutdown);
10981098
assert!(exit_status.is_success());
@@ -1106,7 +1106,7 @@ mod test {
11061106
})
11071107
}
11081108
1109-
let test_function: proc() = || {
1109+
let test_function: proc() = proc() {
11101110
let io = unsafe { local_io() };
11111111
let addr = next_test_ip4();
11121112
let maybe_socket = io.udp_bind(addr);

0 commit comments

Comments
 (0)