2012-12-10 17:32:48 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-05-22 16:57:53 -07:00
|
|
|
use std::string::String;
|
2011-06-15 11:19:50 -07:00
|
|
|
|
2014-12-31 17:32:49 +13:00
|
|
|
#[derive(PartialEq)]
|
2014-05-22 16:57:53 -07:00
|
|
|
enum t { a, b(String), }
|
2010-11-19 14:59:58 -08:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn make(i: isize) -> t {
|
2014-11-06 00:05:53 -08:00
|
|
|
if i > 10 { return t::a; }
|
2015-06-08 16:55:35 +02:00
|
|
|
let mut s = String::from("hello");
|
2011-06-15 11:19:50 -07:00
|
|
|
// Ensure s is non-const.
|
|
|
|
|
2013-06-11 19:13:42 -07:00
|
|
|
s.push_str("there");
|
2014-11-06 00:05:53 -08:00
|
|
|
return t::b(s);
|
2010-11-19 14:59:58 -08:00
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2012-03-22 08:39:41 -07:00
|
|
|
let mut i = 0;
|
2011-07-27 14:19:39 +02:00
|
|
|
|
2011-06-15 11:19:50 -07:00
|
|
|
|
|
|
|
// The auto slot for the result of make(i) should not leak.
|
2014-11-06 00:05:53 -08:00
|
|
|
while make(i) != t::a { i += 1; }
|
2011-08-19 15:16:48 -07:00
|
|
|
}
|