/src/test/run-pass/pattern-bound-var-in-for-each.rs

http://github.com/jruderman/rust · Rust · 18 lines · 12 code · 3 blank · 3 comment · 3 complexity · 06c85972acf8697227ab0063abadcbd1 MD5 · raw file

  1. // Tests that trans_path checks whether a
  2. // pattern-bound var is an upvar (when translating
  3. // the for-each body)
  4. fn foo(src: uint) {
  5. match some(src) {
  6. some(src_id) => {
  7. for uint::range(0u, 10u) |i| {
  8. let yyy = src_id;
  9. assert (yyy == 0u);
  10. }
  11. }
  12. _ => { }
  13. }
  14. }
  15. fn main() { foo(0u); }