Skip to content
This repository
Browse code

Add an infinite loop construct

Add a loop {} construct for infinite loops, and use it in test
cases. See #1906 for details.
  • Loading branch information...
commit 321fd80219e024cabb7ee539e701bc6b4a258751 1 parent 4ffcb95
Tim Chevalier authored March 09, 2012

Showing 33 changed files with 208 additions and 122 deletions. Show diff stats Hide diff stats

  1. 4  src/libcore/uint.rs
  2. 62  src/libstd/uv.rs
  3. 111  src/rustc/metadata/astencode_gen.rs
  4. 10  src/rustc/middle/last_use.rs
  5. 17  src/rustc/middle/trans/base.rs
  6. 13  src/rustc/middle/tstate/pre_post_conditions.rs
  7. 18  src/rustc/middle/tstate/states.rs
  8. 5  src/rustc/middle/typeck.rs
  9. 4  src/rustc/syntax/ast.rs
  10. 5  src/rustc/syntax/fold.rs
  11. 21  src/rustc/syntax/parse/parser.rs
  12. 5  src/rustc/syntax/print/pprust.rs
  13. 1  src/rustc/syntax/visit.rs
  14. 2  src/rustdoc/markdown_writer.rs
  15. 2  src/rustdoc/page_pass.rs
  16. 2  src/test/bench/shootout-pfib.rs
  17. 4  src/test/bench/task-perf-word-count-generic.rs
  18. 4  src/test/bench/task-perf-word-count.rs
  19. 2  src/test/compile-fail/block-must-not-have-result-while.rs
  20. 2  src/test/compile-fail/while-bypass.rs
  21. 8  src/test/compile-fail/while-loop-constraints.rs
  22. 4  src/test/compile-fail/while-loop-pred-constraints.rs
  23. 2  src/test/run-pass/acyclic-unwind.rs
  24. 2  src/test/run-pass/break-value.rs
  25. 2  src/test/run-pass/infinite-loops.rs
  26. 4  src/test/run-pass/issue-687.rs
  27. 2  src/test/run-pass/last-use-corner-cases.rs
  28. 2  src/test/run-pass/last-use-in-block.rs
  29. 2  src/test/run-pass/preempt.rs
  30. 2  src/test/run-pass/send-iloop.rs
  31. 2  src/test/run-pass/terminate-in-initializer.rs
  32. 2  src/test/run-pass/unreachable-code.rs
  33. 2  src/test/run-pass/weird-exprs.rs
4  src/libcore/uint.rs
@@ -138,7 +138,7 @@ fn range(lo: uint, hi: uint, it: fn(uint)) {
138 138
 }
139 139
 
140 140
 /*
141  
-Function: loop
  141
+Function: iterate
142 142
 
143 143
 Iterate over the range [`lo`..`hi`), or stop when requested
144 144
 
@@ -153,7 +153,7 @@ Returns:
153 153
 `true` If execution proceeded correctly, `false` if it was interrupted,
154 154
 that is if `it` returned `false` at any point.
155 155
 */
156  
-fn loop(lo: uint, hi: uint, it: fn(uint) -> bool) -> bool {
  156
+fn iterate(lo: uint, hi: uint, it: fn(uint) -> bool) -> bool {
157 157
     let mut i = lo;
158 158
     while i < hi {
159 159
         if (!it(i)) { ret false; }
62  src/libstd/uv.rs
@@ -53,11 +53,11 @@ enum uv_loop {
53 53
 #[nolink]
54 54
 native mod rustrt {
55 55
     fn rust_uv_loop_new() -> *ctypes::void;
56  
-    fn rust_uv_loop_delete(loop: *ctypes::void);
  56
+    fn rust_uv_loop_delete(lp: *ctypes::void);
57 57
     fn rust_uv_loop_set_data(
58  
-        loop: *ctypes::void,
  58
+        lp: *ctypes::void,
59 59
         data: *uv_loop_data);
60  
-    fn rust_uv_bind_op_cb(loop: *ctypes::void, cb: *u8)
  60
+    fn rust_uv_bind_op_cb(lp: *ctypes::void, cb: *u8)
61 61
         -> *ctypes::void;
62 62
     fn rust_uv_stop_op_cb(handle: *ctypes::void);
63 63
     fn rust_uv_run(loop_handle: *ctypes::void);
@@ -317,37 +317,37 @@ fn loop_new() -> uv_loop unsafe {
317 317
     ret comm::recv(ret_recv_port);
318 318
 }
319 319
 
320  
-fn loop_delete(loop: uv_loop) {
321  
-    let loop_ptr = get_loop_ptr_from_uv_loop(loop);
  320
+fn loop_delete(lp: uv_loop) {
  321
+    let loop_ptr = get_loop_ptr_from_uv_loop(lp);
322 322
     rustrt::rust_uv_loop_delete(loop_ptr);
323 323
 }
324 324
 
325  
-fn run(loop: uv_loop) {
  325
+fn run(lp: uv_loop) {
326 326
     let end_port = comm::port::<bool>();
327 327
     let end_chan = comm::chan::<bool>(end_port);
328  
-    let loop_chan = get_loop_chan_from_uv_loop(loop);
  328
+    let loop_chan = get_loop_chan_from_uv_loop(lp);
329 329
     comm::send(loop_chan, msg_run(end_chan));
330 330
     comm::recv(end_port);
331 331
 }
332 332
 
333  
-fn run_in_bg(loop: uv_loop) {
334  
-    let loop_chan = get_loop_chan_from_uv_loop(loop);
  333
+fn run_in_bg(lp: uv_loop) {
  334
+    let loop_chan = get_loop_chan_from_uv_loop(lp);
335 335
     comm::send(loop_chan, msg_run_in_bg);
336 336
 }
337 337
 
338 338
 fn async_init (
339  
-    loop: uv_loop,
  339
+    lp: uv_loop,
340 340
     async_cb: fn~(uv_handle),
341 341
     after_cb: fn~(uv_handle)) {
342 342
     let msg = msg_async_init(async_cb, after_cb);
343  
-    let loop_chan = get_loop_chan_from_uv_loop(loop);
  343
+    let loop_chan = get_loop_chan_from_uv_loop(lp);
344 344
     comm::send(loop_chan, msg);
345 345
 }
346 346
 
347 347
 fn async_send(async: uv_handle) {
348 348
     alt async {
349  
-      uv_async(id, loop) {
350  
-        let loop_chan = get_loop_chan_from_uv_loop(loop);
  349
+      uv_async(id, lp) {
  350
+        let loop_chan = get_loop_chan_from_uv_loop(lp);
351 351
         comm::send(loop_chan, msg_async_send(id));
352 352
       }
353 353
       _ {
@@ -362,18 +362,18 @@ fn close(h: uv_handle, cb: fn~()) {
362 362
     comm::send(loop_chan, msg_close(h, cb));
363 363
 }
364 364
 
365  
-fn timer_init(loop: uv_loop, after_cb: fn~(uv_handle)) {
  365
+fn timer_init(lp: uv_loop, after_cb: fn~(uv_handle)) {
366 366
     let msg = msg_timer_init(after_cb);
367  
-    let loop_chan = get_loop_chan_from_uv_loop(loop);
  367
+    let loop_chan = get_loop_chan_from_uv_loop(lp);
368 368
     comm::send(loop_chan, msg);
369 369
 }
370 370
 
371 371
 fn timer_start(the_timer: uv_handle, timeout: u32, repeat:u32,
372 372
                timer_cb: fn~(uv_handle)) {
373 373
     alt the_timer {
374  
-      uv_timer(id, loop) {
  374
+      uv_timer(id, lp) {
375 375
         let msg = msg_timer_start(id, timeout, repeat, timer_cb);
376  
-        let loop_chan = get_loop_chan_from_uv_loop(loop);
  376
+        let loop_chan = get_loop_chan_from_uv_loop(lp);
377 377
         comm::send(loop_chan, msg);
378 378
       }
379 379
       _ {
@@ -385,8 +385,8 @@ fn timer_start(the_timer: uv_handle, timeout: u32, repeat:u32,
385 385
 
386 386
 fn timer_stop(the_timer: uv_handle, after_cb: fn~(uv_handle)) {
387 387
     alt the_timer {
388  
-      uv_timer(id, loop) {
389  
-        let loop_chan = get_loop_chan_from_uv_loop(loop);
  388
+      uv_timer(id, lp) {
  389
+        let loop_chan = get_loop_chan_from_uv_loop(lp);
390 390
         let msg = msg_timer_stop(id, after_cb);
391 391
         comm::send(loop_chan, msg);
392 392
       }
@@ -423,8 +423,8 @@ fn get_loop_chan_from_data(data: *uv_loop_data)
423 423
 fn get_loop_chan_from_handle(handle: uv_handle)
424 424
     -> comm::chan<uv_msg> {
425 425
     alt handle {
426  
-      uv_async(id,loop) | uv_timer(id,loop) {
427  
-        let loop_chan = get_loop_chan_from_uv_loop(loop);
  426
+      uv_async(id,lp) | uv_timer(id,lp) {
  427
+        let loop_chan = get_loop_chan_from_uv_loop(lp);
428 428
         ret loop_chan;
429 429
       }
430 430
       _ {
@@ -434,15 +434,15 @@ fn get_loop_chan_from_handle(handle: uv_handle)
434 434
     }
435 435
 }
436 436
 
437  
-fn get_loop_ptr_from_uv_loop(loop: uv_loop) -> *ctypes::void {
438  
-    alt loop {
  437
+fn get_loop_ptr_from_uv_loop(lp: uv_loop) -> *ctypes::void {
  438
+    alt lp {
439 439
       uv_loop_new(loop_chan, loop_ptr) {
440 440
         ret loop_ptr;
441 441
       }
442 442
     }
443 443
 }
444  
-fn get_loop_chan_from_uv_loop(loop: uv_loop) -> comm::chan<uv_msg> {
445  
-    alt loop {
  444
+fn get_loop_chan_from_uv_loop(lp: uv_loop) -> comm::chan<uv_msg> {
  445
+    alt lp {
446 446
       uv_loop_new(loop_chan, loop_ptr) {
447 447
         ret loop_chan;
448 448
       }
@@ -451,7 +451,7 @@ fn get_loop_chan_from_uv_loop(loop: uv_loop) -> comm::chan<uv_msg> {
451 451
 
452 452
 fn get_id_from_handle(handle: uv_handle) -> [u8] {
453 453
     alt handle {
454  
-      uv_async(id,loop) | uv_timer(id,loop) {
  454
+      uv_async(id,lp) | uv_timer(id,lp) {
455 455
         ret id;
456 456
       }
457 457
       _ {
@@ -462,7 +462,7 @@ fn get_id_from_handle(handle: uv_handle) -> [u8] {
462 462
 
463 463
 // crust
464 464
 crust fn process_operation(
465  
-        loop: *ctypes::void,
  465
+        lp: *ctypes::void,
466 466
         data: *uv_loop_data) unsafe {
467 467
     let op_port = (*data).operation_port;
468 468
     let loop_chan = get_loop_chan_from_data(data);
@@ -472,7 +472,7 @@ crust fn process_operation(
472 472
           op_async_init(id) {
473 473
             let id_ptr = vec::unsafe::to_ptr(id);
474 474
             let async_handle = rustrt::rust_uv_async_init(
475  
-                loop,
  475
+                lp,
476 476
                 process_async_send,
477 477
                 id_ptr);
478 478
             comm::send(loop_chan, uv_async_init(
@@ -485,7 +485,7 @@ crust fn process_operation(
485 485
           op_timer_init(id) {
486 486
             let id_ptr = vec::unsafe::to_ptr(id);
487 487
             let timer_handle = rustrt::rust_uv_timer_init(
488  
-                loop,
  488
+                lp,
489 489
                 process_timer_call,
490 490
                 id_ptr);
491 491
             comm::send(loop_chan, uv_timer_init(
@@ -515,12 +515,12 @@ crust fn process_operation(
515 515
 fn handle_op_close(handle: uv_handle, handle_ptr: *ctypes::void) {
516 516
     // it's just like im doing C
517 517
     alt handle {
518  
-      uv_async(id, loop) {
  518
+      uv_async(id, lp) {
519 519
         let cb = process_close_async;
520 520
         rustrt::rust_uv_close(
521 521
             handle_ptr, cb);
522 522
       }
523  
-      uv_timer(id, loop) {
  523
+      uv_timer(id, lp) {
524 524
         let cb = process_close_timer;
525 525
         rustrt::rust_uv_close(
526 526
             handle_ptr, cb);
111  src/rustc/metadata/astencode_gen.rs
@@ -2419,6 +2419,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2419 2419
                 /*@syntax::ast::local*//*@syntax::ast::expr*/
2420 2420
                 /*syntax::ast::blk*/
2421 2421
                 /*syntax::ast::blk*//*@syntax::ast::expr*/
  2422
+                /*syntax::ast::blk*/
2422 2423
                 /*@syntax::ast::expr*//*[syntax::ast::arm]*/
2423 2424
                 /*syntax::ast::alt_mode*/
2424 2425
                 /*syntax::ast::proto*//*syntax::ast::fn_decl*/
@@ -2683,8 +2684,20 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2683 2684
                                                 }
2684 2685
                                             })
2685 2686
                       }
  2687
+                      syntax::ast::expr_loop(v0) {
  2688
+                        s.emit_enum_variant("syntax::ast::expr_loop", 13u, 1u,
  2689
+                                            {||
  2690
+                                                {
  2691
+                                                    s.emit_enum_variant_arg(0u,
  2692
+                                                                            {||
  2693
+                                                                                serialize_83(s,
  2694
+                                                                                             v0)
  2695
+                                                                            })
  2696
+                                                }
  2697
+                                            })
  2698
+                      }
2686 2699
                       syntax::ast::expr_alt(v0, v1, v2) {
2687  
-                        s.emit_enum_variant("syntax::ast::expr_alt", 13u, 3u,
  2700
+                        s.emit_enum_variant("syntax::ast::expr_alt", 14u, 3u,
2688 2701
                                             {||
2689 2702
                                                 {
2690 2703
                                                     s.emit_enum_variant_arg(0u,
@@ -2706,7 +2719,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2706 2719
                                             })
2707 2720
                       }
2708 2721
                       syntax::ast::expr_fn(v0, v1, v2, v3) {
2709  
-                        s.emit_enum_variant("syntax::ast::expr_fn", 14u, 4u,
  2722
+                        s.emit_enum_variant("syntax::ast::expr_fn", 15u, 4u,
2710 2723
                                             {||
2711 2724
                                                 {
2712 2725
                                                     s.emit_enum_variant_arg(0u,
@@ -2733,7 +2746,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2733 2746
                                             })
2734 2747
                       }
2735 2748
                       syntax::ast::expr_fn_block(v0, v1) {
2736  
-                        s.emit_enum_variant("syntax::ast::expr_fn_block", 15u,
  2749
+                        s.emit_enum_variant("syntax::ast::expr_fn_block", 16u,
2737 2750
                                             2u,
2738 2751
                                             {||
2739 2752
                                                 {
@@ -2751,7 +2764,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2751 2764
                                             })
2752 2765
                       }
2753 2766
                       syntax::ast::expr_block(v0) {
2754  
-                        s.emit_enum_variant("syntax::ast::expr_block", 16u,
  2767
+                        s.emit_enum_variant("syntax::ast::expr_block", 17u,
2755 2768
                                             1u,
2756 2769
                                             {||
2757 2770
                                                 {
@@ -2764,7 +2777,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2764 2777
                                             })
2765 2778
                       }
2766 2779
                       syntax::ast::expr_copy(v0) {
2767  
-                        s.emit_enum_variant("syntax::ast::expr_copy", 17u, 1u,
  2780
+                        s.emit_enum_variant("syntax::ast::expr_copy", 18u, 1u,
2768 2781
                                             {||
2769 2782
                                                 {
2770 2783
                                                     s.emit_enum_variant_arg(0u,
@@ -2776,7 +2789,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2776 2789
                                             })
2777 2790
                       }
2778 2791
                       syntax::ast::expr_move(v0, v1) {
2779  
-                        s.emit_enum_variant("syntax::ast::expr_move", 18u, 2u,
  2792
+                        s.emit_enum_variant("syntax::ast::expr_move", 19u, 2u,
2780 2793
                                             {||
2781 2794
                                                 {
2782 2795
                                                     s.emit_enum_variant_arg(0u,
@@ -2793,7 +2806,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2793 2806
                                             })
2794 2807
                       }
2795 2808
                       syntax::ast::expr_assign(v0, v1) {
2796  
-                        s.emit_enum_variant("syntax::ast::expr_assign", 19u,
  2809
+                        s.emit_enum_variant("syntax::ast::expr_assign", 20u,
2797 2810
                                             2u,
2798 2811
                                             {||
2799 2812
                                                 {
@@ -2811,7 +2824,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2811 2824
                                             })
2812 2825
                       }
2813 2826
                       syntax::ast::expr_swap(v0, v1) {
2814  
-                        s.emit_enum_variant("syntax::ast::expr_swap", 20u, 2u,
  2827
+                        s.emit_enum_variant("syntax::ast::expr_swap", 21u, 2u,
2815 2828
                                             {||
2816 2829
                                                 {
2817 2830
                                                     s.emit_enum_variant_arg(0u,
@@ -2829,7 +2842,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2829 2842
                       }
2830 2843
                       syntax::ast::expr_assign_op(v0, v1, v2) {
2831 2844
                         s.emit_enum_variant("syntax::ast::expr_assign_op",
2832  
-                                            21u, 3u,
  2845
+                                            22u, 3u,
2833 2846
                                             {||
2834 2847
                                                 {
2835 2848
                                                     s.emit_enum_variant_arg(0u,
@@ -2851,7 +2864,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2851 2864
                                             })
2852 2865
                       }
2853 2866
                       syntax::ast::expr_field(v0, v1, v2) {
2854  
-                        s.emit_enum_variant("syntax::ast::expr_field", 22u,
  2867
+                        s.emit_enum_variant("syntax::ast::expr_field", 23u,
2855 2868
                                             3u,
2856 2869
                                             {||
2857 2870
                                                 {
@@ -2874,7 +2887,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2874 2887
                                             })
2875 2888
                       }
2876 2889
                       syntax::ast::expr_index(v0, v1) {
2877  
-                        s.emit_enum_variant("syntax::ast::expr_index", 23u,
  2890
+                        s.emit_enum_variant("syntax::ast::expr_index", 24u,
2878 2891
                                             2u,
2879 2892
                                             {||
2880 2893
                                                 {
@@ -2892,7 +2905,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2892 2905
                                             })
2893 2906
                       }
2894 2907
                       syntax::ast::expr_path(v0) {
2895  
-                        s.emit_enum_variant("syntax::ast::expr_path", 24u, 1u,
  2908
+                        s.emit_enum_variant("syntax::ast::expr_path", 25u, 1u,
2896 2909
                                             {||
2897 2910
                                                 {
2898 2911
                                                     s.emit_enum_variant_arg(0u,
@@ -2904,7 +2917,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2904 2917
                                             })
2905 2918
                       }
2906 2919
                       syntax::ast::expr_addr_of(v0, v1) {
2907  
-                        s.emit_enum_variant("syntax::ast::expr_addr_of", 25u,
  2920
+                        s.emit_enum_variant("syntax::ast::expr_addr_of", 26u,
2908 2921
                                             2u,
2909 2922
                                             {||
2910 2923
                                                 {
@@ -2922,7 +2935,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2922 2935
                                             })
2923 2936
                       }
2924 2937
                       syntax::ast::expr_fail(v0) {
2925  
-                        s.emit_enum_variant("syntax::ast::expr_fail", 26u, 1u,
  2938
+                        s.emit_enum_variant("syntax::ast::expr_fail", 27u, 1u,
2926 2939
                                             {||
2927 2940
                                                 {
2928 2941
                                                     s.emit_enum_variant_arg(0u,
@@ -2934,15 +2947,15 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2934 2947
                                             })
2935 2948
                       }
2936 2949
                       syntax::ast::expr_break {
2937  
-                        s.emit_enum_variant("syntax::ast::expr_break", 27u,
  2950
+                        s.emit_enum_variant("syntax::ast::expr_break", 28u,
2938 2951
                                             0u, {|| })
2939 2952
                       }
2940 2953
                       syntax::ast::expr_cont {
2941  
-                        s.emit_enum_variant("syntax::ast::expr_cont", 28u, 0u,
  2954
+                        s.emit_enum_variant("syntax::ast::expr_cont", 29u, 0u,
2942 2955
                                             {|| })
2943 2956
                       }
2944 2957
                       syntax::ast::expr_ret(v0) {
2945  
-                        s.emit_enum_variant("syntax::ast::expr_ret", 29u, 1u,
  2958
+                        s.emit_enum_variant("syntax::ast::expr_ret", 30u, 1u,
2946 2959
                                             {||
2947 2960
                                                 {
2948 2961
                                                     s.emit_enum_variant_arg(0u,
@@ -2954,7 +2967,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2954 2967
                                             })
2955 2968
                       }
2956 2969
                       syntax::ast::expr_be(v0) {
2957  
-                        s.emit_enum_variant("syntax::ast::expr_be", 30u, 1u,
  2970
+                        s.emit_enum_variant("syntax::ast::expr_be", 31u, 1u,
2958 2971
                                             {||
2959 2972
                                                 {
2960 2973
                                                     s.emit_enum_variant_arg(0u,
@@ -2966,7 +2979,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2966 2979
                                             })
2967 2980
                       }
2968 2981
                       syntax::ast::expr_log(v0, v1, v2) {
2969  
-                        s.emit_enum_variant("syntax::ast::expr_log", 31u, 3u,
  2982
+                        s.emit_enum_variant("syntax::ast::expr_log", 32u, 3u,
2970 2983
                                             {||
2971 2984
                                                 {
2972 2985
                                                     s.emit_enum_variant_arg(0u,
@@ -2988,7 +3001,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
2988 3001
                                             })
2989 3002
                       }
2990 3003
                       syntax::ast::expr_assert(v0) {
2991  
-                        s.emit_enum_variant("syntax::ast::expr_assert", 32u,
  3004
+                        s.emit_enum_variant("syntax::ast::expr_assert", 33u,
2992 3005
                                             1u,
2993 3006
                                             {||
2994 3007
                                                 {
@@ -3001,7 +3014,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
3001 3014
                                             })
3002 3015
                       }
3003 3016
                       syntax::ast::expr_check(v0, v1) {
3004  
-                        s.emit_enum_variant("syntax::ast::expr_check", 33u,
  3017
+                        s.emit_enum_variant("syntax::ast::expr_check", 34u,
3005 3018
                                             2u,
3006 3019
                                             {||
3007 3020
                                                 {
@@ -3019,7 +3032,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
3019 3032
                                             })
3020 3033
                       }
3021 3034
                       syntax::ast::expr_if_check(v0, v1, v2) {
3022  
-                        s.emit_enum_variant("syntax::ast::expr_if_check", 34u,
  3035
+                        s.emit_enum_variant("syntax::ast::expr_if_check", 35u,
3023 3036
                                             3u,
3024 3037
                                             {||
3025 3038
                                                 {
@@ -3042,7 +3055,7 @@ fn serialize_74<S: std::serialization::serializer>(s: S,
3042 3055
                                             })
3043 3056
                       }
3044 3057
                       syntax::ast::expr_mac(v0) {
3045  
-                        s.emit_enum_variant("syntax::ast::expr_mac", 35u, 1u,
  3058
+                        s.emit_enum_variant("syntax::ast::expr_mac", 36u, 1u,
3046 3059
                                             {||
3047 3060
                                                 {
3048 3061
                                                     s.emit_enum_variant_arg(0u,
@@ -6596,6 +6609,8 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6596 6609
 
6597 6610
                 /*syntax::ast::blk*//*@syntax::ast::expr*/
6598 6611
 
  6612
+                /*syntax::ast::blk*/
  6613
+
6599 6614
                 /*@syntax::ast::expr*//*[syntax::ast::arm]*/
6600 6615
                 /*syntax::ast::alt_mode*/
6601 6616
 
@@ -6788,6 +6803,12 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6788 6803
                                                                                                    }))
6789 6804
                                               }
6790 6805
                                               13u {
  6806
+                                                syntax::ast::expr_loop(s.read_enum_variant_arg(0u,
  6807
+                                                                                               {||
  6808
+                                                                                                   deserialize_83(s)
  6809
+                                                                                               }))
  6810
+                                              }
  6811
+                                              14u {
6791 6812
                                                 syntax::ast::expr_alt(s.read_enum_variant_arg(0u,
6792 6813
                                                                                               {||
6793 6814
                                                                                                   deserialize_72(s)
@@ -6801,7 +6822,7 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6801 6822
                                                                                                   deserialize_123(s)
6802 6823
                                                                                               }))
6803 6824
                                               }
6804  
-                                              14u {
  6825
+                                              15u {
6805 6826
                                                 syntax::ast::expr_fn(s.read_enum_variant_arg(0u,
6806 6827
                                                                                              {||
6807 6828
                                                                                                  deserialize_39(s)
@@ -6819,7 +6840,7 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6819 6840
                                                                                                  deserialize_124(s)
6820 6841
                                                                                              }))
6821 6842
                                               }
6822  
-                                              15u {
  6843
+                                              16u {
6823 6844
                                                 syntax::ast::expr_fn_block(s.read_enum_variant_arg(0u,
6824 6845
                                                                                                    {||
6825 6846
                                                                                                        deserialize_40(s)
@@ -6829,19 +6850,19 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6829 6850
                                                                                                        deserialize_83(s)
6830 6851
                                                                                                    }))
6831 6852
                                               }
6832  
-                                              16u {
  6853
+                                              17u {
6833 6854
                                                 syntax::ast::expr_block(s.read_enum_variant_arg(0u,
6834 6855
                                                                                                 {||
6835 6856
                                                                                                     deserialize_83(s)
6836 6857
                                                                                                 }))
6837 6858
                                               }
6838  
-                                              17u {
  6859
+                                              18u {
6839 6860
                                                 syntax::ast::expr_copy(s.read_enum_variant_arg(0u,
6840 6861
                                                                                                {||
6841 6862
                                                                                                    deserialize_72(s)
6842 6863
                                                                                                }))
6843 6864
                                               }
6844  
-                                              18u {
  6865
+                                              19u {
6845 6866
                                                 syntax::ast::expr_move(s.read_enum_variant_arg(0u,
6846 6867
                                                                                                {||
6847 6868
                                                                                                    deserialize_72(s)
@@ -6851,7 +6872,7 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6851 6872
                                                                                                    deserialize_72(s)
6852 6873
                                                                                                }))
6853 6874
                                               }
6854  
-                                              19u {
  6875
+                                              20u {
6855 6876
                                                 syntax::ast::expr_assign(s.read_enum_variant_arg(0u,
6856 6877
                                                                                                  {||
6857 6878
                                                                                                      deserialize_72(s)
@@ -6861,7 +6882,7 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6861 6882
                                                                                                      deserialize_72(s)
6862 6883
                                                                                                  }))
6863 6884
                                               }
6864  
-                                              20u {
  6885
+                                              21u {
6865 6886
                                                 syntax::ast::expr_swap(s.read_enum_variant_arg(0u,
6866 6887
                                                                                                {||
6867 6888
                                                                                                    deserialize_72(s)
@@ -6871,7 +6892,7 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6871 6892
                                                                                                    deserialize_72(s)
6872 6893
                                                                                                }))
6873 6894
                                               }
6874  
-                                              21u {
  6895
+                                              22u {
6875 6896
                                                 syntax::ast::expr_assign_op(s.read_enum_variant_arg(0u,
6876 6897
                                                                                                     {||
6877 6898
                                                                                                         deserialize_81(s)
@@ -6885,7 +6906,7 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6885 6906
                                                                                                         deserialize_72(s)
6886 6907
                                                                                                     }))
6887 6908
                                               }
6888  
-                                              22u {
  6909
+                                              23u {
6889 6910
                                                 syntax::ast::expr_field(s.read_enum_variant_arg(0u,
6890 6911
                                                                                                 {||
6891 6912
                                                                                                     deserialize_72(s)
@@ -6899,7 +6920,7 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6899 6920
                                                                                                     deserialize_55(s)
6900 6921
                                                                                                 }))
6901 6922
                                               }
6902  
-                                              23u {
  6923
+                                              24u {
6903 6924
                                                 syntax::ast::expr_index(s.read_enum_variant_arg(0u,
6904 6925
                                                                                                 {||
6905 6926
                                                                                                     deserialize_72(s)
@@ -6909,13 +6930,13 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6909 6930
                                                                                                     deserialize_72(s)
6910 6931
                                                                                                 }))
6911 6932
                                               }
6912  
-                                              24u {
  6933
+                                              25u {
6913 6934
                                                 syntax::ast::expr_path(s.read_enum_variant_arg(0u,
6914 6935
                                                                                                {||
6915 6936
                                                                                                    deserialize_51(s)
6916 6937
                                                                                                }))
6917 6938
                                               }
6918  
-                                              25u {
  6939
+                                              26u {
6919 6940
                                                 syntax::ast::expr_addr_of(s.read_enum_variant_arg(0u,
6920 6941
                                                                                                   {||
6921 6942
                                                                                                       deserialize_33(s)
@@ -6925,27 +6946,27 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6925 6946
                                                                                                       deserialize_72(s)
6926 6947
                                                                                                   }))
6927 6948
                                               }
6928  
-                                              26u {
  6949
+                                              27u {
6929 6950
                                                 syntax::ast::expr_fail(s.read_enum_variant_arg(0u,
6930 6951
                                                                                                {||
6931 6952
                                                                                                    deserialize_79(s)
6932 6953
                                                                                                }))
6933 6954
                                               }
6934  
-                                              27u { syntax::ast::expr_break }
6935  
-                                              28u { syntax::ast::expr_cont }
6936  
-                                              29u {
  6955
+                                              28u { syntax::ast::expr_break }
  6956
+                                              29u { syntax::ast::expr_cont }
  6957
+                                              30u {
6937 6958
                                                 syntax::ast::expr_ret(s.read_enum_variant_arg(0u,
6938 6959
                                                                                               {||
6939 6960
                                                                                                   deserialize_79(s)
6940 6961
                                                                                               }))
6941 6962
                                               }
6942  
-                                              30u {
  6963
+                                              31u {
6943 6964
                                                 syntax::ast::expr_be(s.read_enum_variant_arg(0u,
6944 6965
                                                                                              {||
6945 6966
                                                                                                  deserialize_72(s)
6946 6967
                                                                                              }))
6947 6968
                                               }
6948  
-                                              31u {
  6969
+                                              32u {
6949 6970
                                                 syntax::ast::expr_log(s.read_enum_variant_arg(0u,
6950 6971
                                                                                               {||
6951 6972
                                                                                                   deserialize_129(s)
@@ -6959,13 +6980,13 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6959 6980
                                                                                                   deserialize_72(s)
6960 6981
                                                                                               }))
6961 6982
                                               }
6962  
-                                              32u {
  6983
+                                              33u {
6963 6984
                                                 syntax::ast::expr_assert(s.read_enum_variant_arg(0u,
6964 6985
                                                                                                  {||
6965 6986
                                                                                                      deserialize_72(s)
6966 6987
                                                                                                  }))
6967 6988
                                               }
6968  
-                                              33u {
  6989
+                                              34u {
6969 6990
                                                 syntax::ast::expr_check(s.read_enum_variant_arg(0u,
6970 6991
                                                                                                 {||
6971 6992
                                                                                                     deserialize_130(s)
@@ -6975,7 +6996,7 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6975 6996
                                                                                                     deserialize_72(s)
6976 6997
                                                                                                 }))
6977 6998
                                               }
6978  
-                                              34u {
  6999
+                                              35u {
6979 7000
                                                 syntax::ast::expr_if_check(s.read_enum_variant_arg(0u,
6980 7001
                                                                                                    {||
6981 7002
                                                                                                        deserialize_72(s)
@@ -6989,7 +7010,7 @@ fn deserialize_74<S: std::serialization::deserializer>(s: S) ->
6989 7010
                                                                                                        deserialize_79(s)
6990 7011
                                                                                                    }))
6991 7012
                                               }
6992  
-                                              35u {
  7013
+                                              36u {
6993 7014
                                                 syntax::ast::expr_mac(s.read_enum_variant_arg(0u,
6994 7015
                                                                                               {||
6995 7016
                                                                                                   deserialize_69(s)
10  src/rustc/middle/last_use.rs
@@ -33,7 +33,7 @@ enum is_last_use {
33 33
 type last_uses = std::map::hashmap<node_id, is_last_use>;
34 34
 
35 35
 enum seen { unset, seen(node_id), }
36  
-enum block_type { func, loop, }
  36
+enum block_type { func, lp, }
37 37
 
38 38
 enum use { var_use(node_id), close_over(node_id), }
39 39
 type set = [{def: node_id, uses: list<use>}];
@@ -97,13 +97,13 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
97 97
         visit::visit_expr_opt(oexpr, cx, v);
98 98
         leave_fn(cx);
99 99
       }
100  
-      expr_break { add_block_exit(cx, loop); }
101  
-      expr_while(_, _) | expr_do_while(_, _) {
102  
-        visit_block(loop, cx) {|| visit::visit_expr(ex, cx, v);}
  100
+      expr_break { add_block_exit(cx, lp); }
  101
+      expr_while(_, _) | expr_do_while(_, _) | expr_loop(_) {
  102
+        visit_block(lp, cx) {|| visit::visit_expr(ex, cx, v);}
103 103
       }
104 104
       expr_for(_, coll, blk) {
105 105
         v.visit_expr(coll, cx, v);
106  
-        visit_block(loop, cx) {|| visit::visit_block(blk, cx, v);}
  106
+        visit_block(lp, cx) {|| visit::visit_block(blk, cx, v);}
107 107
       }
108 108
       expr_alt(input, arms, _) {
109 109
         v.visit_expr(input, cx, v);
17  src/rustc/middle/trans/base.rs
@@ -2029,6 +2029,17 @@ fn trans_do_while(cx: block, body: ast::blk, cond: @ast::expr) ->
2029 2029
     ret next_cx;
2030 2030
 }
2031 2031
 
  2032
+fn trans_loop(cx:block, body: ast::blk) -> block {
  2033
+    let next_cx = sub_block(cx, "next");
  2034
+    let body_cx =
  2035
+        loop_scope_block(cx, cont_self, next_cx,
  2036
+                                  "infinite loop body", body.span);
  2037
+    let body_end = trans_block(body_cx, body, ignore);
  2038
+    cleanup_and_Br(body_end, body_cx, body_cx.llbb);
  2039
+    Br(cx, body_cx.llbb);
  2040
+    ret next_cx;
  2041
+}
  2042
+
2032 2043
 type generic_info = {item_type: ty::t,
2033 2044
                      static_tis: [option<@tydesc_info>],
2034 2045
                      tydescs: [ValueRef],
@@ -3255,6 +3266,10 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
3255 3266
         assert dest == ignore;
3256 3267
         ret trans_while(bcx, cond, body);
3257 3268
       }
  3269
+      ast::expr_loop(body) {
  3270
+        assert dest == ignore;
  3271
+        ret trans_loop(bcx, body);
  3272
+      }
3258 3273
       ast::expr_do_while(body, cond) {
3259 3274
         assert dest == ignore;
3260 3275
         ret trans_do_while(bcx, body, cond);
@@ -3293,7 +3308,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
3293 3308
         assert dest == ignore;
3294 3309
         ret trans_assign_op(bcx, e, op, dst, src);
3295 3310
       }
3296  
-      _ { bcx.tcx().sess.span_bug(e.span, "trans_expr reached\
  3311
+      _ { bcx.tcx().sess.span_bug(e.span, "trans_expr reached \
3297 3312
              fall-through case"); }
3298 3313
 
3299 3314
     }
13  src/rustc/middle/tstate/pre_post_conditions.rs
@@ -446,6 +446,19 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
446 446
                                        expr_pp(fcx.ccx, test)]),
447 447
                          loop_postcond);
448 448
       }
  449
+      expr_loop(body) {
  450
+        find_pre_post_block(fcx, body);
  451
+        /* Infinite loop: if control passes it, everything is true. */
  452
+        let loop_postcond = false_postcond(num_local_vars);
  453
+        /* Conservative approximation: if the body has any nonlocal exits,
  454
+         the poststate is blank since we don't know what parts of it
  455
+          execute. */
  456
+        if has_nonlocal_exits(body) {
  457
+            loop_postcond = empty_poststate(num_local_vars);
  458
+        }
  459
+        set_pre_and_post(fcx.ccx, e.id, block_precond(fcx.ccx, body),
  460
+                         loop_postcond);
  461
+      }
449 462
       expr_for(d, index, body) {
450 463
         find_pre_post_loop(fcx, d, index, body, e.id);
451 464
       }
18  src/rustc/middle/tstate/states.rs
@@ -354,7 +354,6 @@ fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id,
354 354
 fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
355 355
     let num_constrs = num_constraints(fcx.enclosing);
356 356
 
357  
-
358 357
     alt e.node {
359 358
       expr_vec(elts, _) {
360 359
         ret find_pre_post_state_exprs(fcx, pres, e.id,
@@ -489,8 +488,6 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
489 488
         */
490 489
         let loop_pres =
491 490
             intersect_states(block_poststate(fcx.ccx, body), pres);
492  
-        // aux::log_tritv_err(fcx, loop_pres);
493  
-        // #error("---------------");
494 491
 
495 492
         let changed =
496 493
             set_prestate_ann(fcx.ccx, e.id, loop_pres) |
@@ -545,6 +542,21 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
545 542
         }
546 543
         ret changed;
547 544
       }
  545
+      expr_loop(body) {
  546
+        let loop_pres =
  547
+            intersect_states(block_poststate(fcx.ccx, body), pres);
  548
+        let changed = set_prestate_ann(fcx.ccx, e.id, loop_pres)
  549
+              | find_pre_post_state_block(fcx, loop_pres, body);
  550
+        /* conservative approximation: if a loop contains a break
  551
+           or cont, we assume nothing about the poststate */
  552
+        /* which is still unsound -- see [Break-unsound] */
  553
+        if has_nonlocal_exits(body) {
  554
+            ret changed | set_poststate_ann(fcx.ccx, e.id, pres);
  555
+        } else {
  556
+            ret changed | set_poststate_ann(fcx.ccx, e.id,
  557
+                             block_poststate(fcx.ccx, body));
  558
+        }
  559
+      }
548 560
       expr_for(d, index, body) {
549 561
         ret find_pre_post_state_loop(fcx, pres, d, index, body, e.id);
550 562
       }
5  src/rustc/middle/typeck.rs
@@ -2323,6 +2323,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2323 2323
               check_block_no_value(fcx, body);
2324 2324
         write_ty(tcx, id, block_ty(tcx, body));
2325 2325
       }
  2326
+      ast::expr_loop(body) {
  2327
+          check_block_no_value(fcx, body);
  2328
+          write_ty(tcx, id, ty::mk_nil(tcx));
  2329
+      }
2326 2330
       ast::expr_alt(expr, arms, _) {
2327 2331
         bot = check_expr(fcx, expr);
2328 2332
 
@@ -2613,7 +2617,6 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2613 2617
           }
2614 2618
         }
2615 2619
       }
2616  
-      _ { tcx.sess.unimpl("expr type in typeck::check_expr"); }
2617 2620
     }
2618 2621
     if bot { write_ty(tcx, expr.id, ty::mk_bot(tcx)); }
2619 2622
 
4  src/rustc/syntax/ast.rs
@@ -229,6 +229,10 @@ enum expr_ {
229 229
     expr_while(@expr, blk),
230 230
     expr_for(@local, @expr, blk),
231 231
     expr_do_while(blk, @expr),
  232
+    /* Conditionless loop (can be exited with break, cont, ret, or fail)
  233
+       Same semantics as while(true) { body }, but typestate knows that the
  234
+       (implicit) condition is always true. */
  235
+    expr_loop(blk),
232 236
     expr_alt(@expr, [arm], alt_mode),
233 237
     expr_fn(proto, fn_decl, blk, @capture_clause),
234 238
     expr_fn_block(fn_decl, blk),
5  src/rustc/syntax/fold.rs
@@ -380,7 +380,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
380 380
     let fold_mac = bind fold_mac_(_, fld);
381 381
 
382 382
     ret alt e {
383  
-            expr_vec(exprs, mutt) {
  383
+          expr_vec(exprs, mutt) {
384 384
             expr_vec(fld.map_exprs(fld.fold_expr, exprs), mutt)
385 385
           }
386 386
           expr_rec(fields, maybe_expr) {
@@ -417,6 +417,9 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
417 417
           expr_do_while(blk, expr) {
418 418
             expr_do_while(fld.fold_block(blk), fld.fold_expr(expr))
419 419
           }
  420
+          expr_loop(body) {
  421
+              expr_loop(fld.fold_block(body))
  422
+          }
420 423
           expr_alt(expr, arms, mode) {
421 424
             expr_alt(fld.fold_expr(expr), vec::map(arms, fld.fold_arm), mode)
422 425
           }
21  src/rustc/syntax/parse/parser.rs
@@ -146,11 +146,11 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader,
146 146
 fn bad_expr_word_table() -> hashmap<str, ()> {
147 147
     let words = new_str_hash();
148 148
     for word in ["alt", "assert", "be", "break", "check", "claim",
149  
-                 "class", "const", "cont", "copy", "do", "else", "enum",
150  
-                 "export", "fail", "fn", "for", "if",  "iface", "impl",
151  
-                 "import", "let", "log", "mod", "mutable", "native", "pure",
152  
-                 "resource", "ret", "trait", "type", "unchecked", "unsafe",
153  
-                 "while", "crust", "mut"] {
  149
+                 "class", "const", "cont", "copy", "crust", "do", "else",
  150
+                 "enum", "export", "fail", "fn", "for", "if",  "iface",
  151
+                 "impl", "import", "let", "log", "loop", "mod", "mut",
  152
+                 "mutable", "native", "pure", "resource", "ret", "trait",
  153
+                 "type", "unchecked", "unsafe", "while"] {
154 154
         words.insert(word, ());
155 155
     }
156 156
     words
@@ -839,6 +839,8 @@ fn parse_bottom_expr(p: parser) -> pexpr {
839 839
         ret pexpr(parse_while_expr(p));
840 840
     } else if eat_word(p, "do") {
841 841
         ret pexpr(parse_do_while_expr(p));
  842
+    } else if eat_word(p, "loop") {
  843
+        ret pexpr(parse_loop_expr(p));
842 844
     } else if eat_word(p, "alt") {
843 845
         ret pexpr(parse_alt_expr(p));
844 846
     } else if eat_word(p, "fn") {
@@ -1399,6 +1401,13 @@ fn parse_do_while_expr(p: parser) -> @ast::expr {
1399 1401
     ret mk_expr(p, lo, hi, ast::expr_do_while(body, cond));
1400 1402
 }
1401 1403
 
  1404
+fn parse_loop_expr(p: parser) -> @ast::expr {
  1405
+    let lo = p.last_span.lo;
  1406
+    let body = parse_block_no_value(p);
  1407
+    let hi = body.span.hi;
  1408
+    ret mk_expr(p, lo, hi, ast::expr_loop(body));
  1409
+}
  1410
+
1402 1411
 fn parse_alt_expr(p: parser) -> @ast::expr {
1403 1412
     let lo = p.last_span.lo;
1404 1413
     let mode = if eat_word(p, "check") { ast::alt_check }
@@ -1691,7 +1700,7 @@ fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool {
1691 1700
       ast::expr_if(_, _, _) | ast::expr_if_check(_, _, _)
1692 1701
       | ast::expr_alt(_, _, _) | ast::expr_block(_)
1693 1702
       | ast::expr_do_while(_, _) | ast::expr_while(_, _)
1694  
-      | ast::expr_for(_, _, _)
  1703
+      | ast::expr_loop(_) | ast::expr_for(_, _, _)
1695 1704
       | ast::expr_call(_, _, true) {
1696 1705
         false
1697 1706
       }
5  src/rustc/syntax/print/pprust.rs
@@ -913,6 +913,11 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
913 913
         space(s.s);
914 914
         print_block(s, blk);
915 915
       }
  916
+      ast::expr_loop(blk) {
  917
+        head(s, "loop");
  918
+        space(s.s);
  919
+        print_block(s, blk);
  920
+      }
916 921
       ast::expr_for(decl, expr, blk) {
917 922
         head(s, "for");
918 923
         print_for_decl(s, decl, expr);
1  src/rustc/syntax/visit.rs
@@ -343,6 +343,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
343 343
         visit_expr_opt(eo, e, v);
344 344
       }
345 345
       expr_while(x, b) { v.visit_expr(x, e, v); v.visit_block(b, e, v); }
  346
+      expr_loop(b)     { v.visit_block(b, e, v); }
346 347
       expr_for(dcl, x, b) {
347 348
         v.visit_local(dcl, e, v);
348 349
         v.visit_expr(x, e, v);
2  src/rustdoc/markdown_writer.rs
@@ -289,7 +289,7 @@ fn future_writer() -> (writer, future::future<str>) {
289 289
     };
290 290
     let future = future::from_fn {||
291 291
         let res = "";
292  
-        while true {
  292
+        loop {
293 293
             alt comm::recv(port) {
294 294
               write(s) { res += s }
295 295
               done { break }
2  src/rustdoc/page_pass.rs
@@ -43,7 +43,7 @@ type page_chan = comm::chan<option<doc::page>>;
43 43
 
44 44
 fn make_doc_from_pages(page_port: page_port) -> doc::doc {
45 45
     let mut pages = [];
46  
-    while true {
  46
+    loop {
47 47
         let val = comm::recv(page_port);
48 48
         if option::is_some(val) {
49 49
             pages += [option::unwrap(val)];
2  src/test/bench/shootout-pfib.rs
@@ -60,7 +60,7 @@ fn parse_opts(argv: [str]) -> config {
60 60
 
61 61
 fn stress_task(&&id: int) {
62 62
     let i = 0;
63  
-    while true {
  63
+    loop {
64 64
         let n = 15;
65 65
         assert (fib(n) == fib(n));
66 66
         i += 1;
4  src/test/bench/task-perf-word-count-generic.rs
@@ -34,7 +34,7 @@ import comm::send;
34 34
 fn map(&&filename: [u8], emit: map_reduce::putter<[u8], int>) {
35 35
     let f = io::file_reader(str::from_bytes(filename));
36 36
 
37  
-    while true {
  37
+    loop {
38 38
         alt read_word(f) {
39 39
           some(w) { emit(str::bytes(w), 1); }
40 40
           none { break; }
@@ -45,7 +45,7 @@ fn map(&&filename: [u8], emit: map_reduce::putter<[u8], int>) {
45 45
 fn reduce(&&_word: [u8], get: map_reduce::getter<int>) {
46 46
     let count = 0;
47 47
 
48  
-    while true { alt get() { some(_) { count += 1; } none { break; } } }
  48
+    loop { alt get() { some(_) { count += 1; } none { break; } } }
49 49
 }
50 50
 
51 51
 mod map_reduce {
4  src/test/bench/task-perf-word-count.rs
@@ -25,7 +25,7 @@ fn map(input: str, emit: map_reduce::putter) {
25 25
     let f = io::str_reader(input);
26 26
 
27 27
 
28  
-    while true {
  28
+    loop {
29 29
         alt read_word(f) { some(w) { emit(w, 1); } none { break; } }
30 30
     }
31 31
 }
@@ -33,7 +33,7 @@ fn map(input: str, emit: map_reduce::putter) {
33 33
 fn reduce(_word: str, get: map_reduce::getter) {
34 34
     let count = 0;
35 35
 
36  
-    while true { alt get() { some(_) { count += 1; } none { break; } } }
  36
+    loop { alt get() { some(_) { count += 1; } none { break; } } }
37 37
 }
38 38
 
39 39
 mod map_reduce {
2  src/test/compile-fail/block-must-not-have-result-while.rs
... ...
@@ -1,7 +1,7 @@
1 1
 // error-pattern:mismatched types: expected `()` but found `bool`
2 2
 
3 3
 fn main() {
4  
-    while true {
  4
+    loop {
5 5
         true
6 6
     }
7 7
 }
2  src/test/compile-fail/while-bypass.rs
... ...
@@ -1,5 +1,5 @@
1 1
 // error-pattern: precondition constraint
2 2
 
3  
-fn f() -> int { let x: int; while true { x = 10; } ret x; }
  3
+fn f() -> int { let x: int; while 1 == 1 { x = 10; } ret x; }
4 4
 
5 5
 fn main() { f(); }
8  src/test/compile-fail/while-loop-constraints.rs
@@ -3,11 +3,11 @@ fn main() {
3 3
 
4 4
     let y: int = 42;
5 5
     let x: int;
6  
-    while true {
  6
+    loop {
7 7
         log(debug, y);
8  
-        while true {
9  
-            while true {
10  
-                while true { x <- y; }
  8
+        loop {
  9
+            loop {
  10
+                loop { x <- y; }
11 11
             }
12 12
         }
13 13
     }
4  src/test/compile-fail/while-loop-pred-constraints.rs
@@ -9,8 +9,8 @@ fn main() {
9 9
     let y: int = 42;
10 10
     let x: int = 1;
11 11
     check (even(y));
12  
-    while true {
  12
+    loop {
13 13
         print_even(y);
14  
-        while true { while true { while true { y += x; } } }
  14
+        loop { loop { loop { y += x; } } }
15 15
     }
16 16
 }
2  src/test/run-pass/acyclic-unwind.rs
@@ -15,7 +15,7 @@ fn f(c: comm::_chan<int>) {
15 15
     comm::send(c, 1);
16 16
 
17 17
 
18  
-    while true {
  18
+    loop {
19 19
         // spin waiting for the parent to kill us.
20 20
         #debug("child waiting to die...");
21 21
 
2  src/test/run-pass/break-value.rs
... ...
@@ -1,3 +1,3 @@
1 1
 fn int_id(x: int) -> int { ret x; }
2 2
 
3  
-fn main() { while true { int_id(break); } }
  3
+fn main() { loop { int_id(break); } }
2  src/test/run-pass/infinite-loops.rs
@@ -14,7 +14,7 @@ fn loop(n: int) {
14 14
     if n > 0 { t1 = spawn loop(n - 1); t2 = spawn loop(n - 1); }
15 15
 
16 16
 
17  
-    while true { }
  17
+    loop { }
18 18
 }
19 19
 
20 20
 fn main() { let t: task = spawn loop(5); join(t); }
4  src/test/run-pass/issue-687.rs
@@ -18,7 +18,7 @@ fn producer(c: chan<[u8]>) {
18 18
 fn packager(cb: chan<chan<[u8]>>, msg: chan<msg>) {
19 19
     let p: port<[u8]> = port();
20 20
     send(cb, chan(p));
21  
-    while true {
  21
+    loop {
22 22
         #debug("waiting for bytes");
23 23
         let data = recv(p);
24 24
         #debug("got bytes");
@@ -46,7 +46,7 @@ fn main() {
46 46
     let source_chan: chan<[u8]> = recv(recv_reader);
47 47
     let prod = task::spawn {|| producer(source_chan); };
48 48
 
49  
-    while true {
  49
+    loop {
50 50
         let msg = recv(p);
51 51
         alt msg {
52 52
           closed { #debug("Got close message"); break; }
2  src/test/run-pass/last-use-corner-cases.rs
@@ -17,7 +17,7 @@ fn main() {