]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/regions-glb-free-free.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / regions-glb-free-free.rs
CommitLineData
223e47cc
LB
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
11mod argparse {
1a4d82fc
JJ
12 pub struct Flag<'a> {
13 name: &'a str,
54a0048b 14 pub desc: &'a str,
1a4d82fc
JJ
15 max_count: usize,
16 value: usize
223e47cc
LB
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
1a4d82fc
JJ
23 impl<'a> Flag<'a> {
24 pub fn set_desc(self, s: &str) -> Flag<'a> {
54a0048b 25 Flag { //~ ERROR cannot infer
223e47cc 26 name: self.name,
54a0048b 27 desc: s,
223e47cc
LB
28 max_count: self.max_count,
29 value: self.value
30 }
31 }
32 }
33}
34
35fn main () {
1a4d82fc
JJ
36 let f : argparse::Flag = argparse::flag("flag", "My flag");
37 let updated_flag = f.set_desc("My new flag");
85aaf69f 38 assert_eq!(updated_flag.desc, "My new flag");
223e47cc 39}