/src/test/run-pass/while-prelude-drop.rs

http://github.com/jruderman/rust · Rust · 19 lines · 11 code · 6 blank · 2 comment · 3 complexity · 2ec021ece9023b7cad188bf10857715b MD5 · raw file

  1. enum t { a, b(~str), }
  2. fn make(i: int) -> t {
  3. if i > 10 { return a; }
  4. let mut s = ~"hello";
  5. // Ensure s is non-const.
  6. s += ~"there";
  7. return b(s);
  8. }
  9. fn main() {
  10. let mut i = 0;
  11. // The auto slot for the result of make(i) should not leak.
  12. while make(i) != a { i += 1; }
  13. }