]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/regions-glb-free-free.rs
auto merge of #13600 : brandonw/rust/master, r=brson
[rust.git] / src / test / compile-fail / regions-glb-free-free.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 mod argparse {
12     pub struct Flag<'a> {
13         name: &'a str,
14         desc: &'a str,
15         max_count: uint,
16         value: uint
17     }
18
19     pub fn flag<'r>(name: &'r str, desc: &'r str) -> Flag<'r> {
20         Flag { name: name, desc: desc, max_count: 1, value: 0 }
21     }
22
23     impl<'a> Flag<'a> {
24         pub fn set_desc(self, s: &str) -> Flag<'a> {
25             Flag { //~ ERROR cannot infer
26                 name: self.name,
27                 desc: s,
28                 max_count: self.max_count,
29                 value: self.value
30             }
31         }
32     }
33 }
34
35 fn main () {
36     let f : argparse::Flag = argparse::flag(~"flag", ~"My flag");
37     let updated_flag = f.set_desc(~"My new flag");
38     assert_eq!(updated_flag.desc, "My new flag");
39 }