]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lub-match.rs
Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakis
[rust.git] / src / test / ui / lub-match.rs
1 // Test that we correctly consider the type of `match` to be the LUB
2 // of the various arms, particularly in the case where regions are
3 // involved.
4
5 pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
6     match *maybestr {
7         Some(ref s) => {
8             let s: &'a str = s;
9             s
10         }
11         None => "(none)",
12     }
13 }
14
15 pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str {
16     match *maybestr {
17         None => "(none)",
18         Some(ref s) => {
19             let s: &'a str = s;
20             s
21         }
22     }
23 }
24
25 pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
26     match *maybestr {
27         None => "(none)",
28         Some(ref s) => {
29             let s: &'a str = s;
30             s //~ ERROR E0312
31         }
32     }
33 }
34
35 pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
36     match *maybestr {
37         Some(ref s) => {
38             let s: &'a str = s;
39             s //~ ERROR E0312
40         }
41         None => "(none)",
42     }
43 }
44
45 fn main() {}