summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/regions-glb-free-free.rs
blob: 0370a5192d32db23a0c635d23042d843d86143fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
mod argparse {
    pub struct Flag<'a> {
        name: &'a str,
        pub desc: &'a str,
        max_count: usize,
        value: usize
    }

    pub fn flag<'r>(name: &'r str, desc: &'r str) -> Flag<'r> {
        Flag { name: name, desc: desc, max_count: 1, value: 0 }
    }

    impl<'a> Flag<'a> {
        pub fn set_desc(self, s: &str) -> Flag<'a> {
            Flag { //~ ERROR explicit lifetime required in the type of `s` [E0621]
                name: self.name,
                desc: s,
                max_count: self.max_count,
                value: self.value
            }
        }
    }
}

fn main () {
    let f : argparse::Flag = argparse::flag("flag", "My flag");
    let updated_flag = f.set_desc("My new flag");
    assert_eq!(updated_flag.desc, "My new flag");
}