]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lub-if.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / lub-if.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     if maybestr.is_none() {
7         "(none)"
8     } else {
9         let s: &'a str = maybestr.as_ref().unwrap();
10         s
11     }
12 }
13
14 pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str {
15     if maybestr.is_some() {
16         let s: &'a str = maybestr.as_ref().unwrap();
17         s
18     } else {
19         "(none)"
20     }
21 }
22
23 pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
24     if maybestr.is_none() {
25         "(none)"
26     } else {
27         let s: &'a str = maybestr.as_ref().unwrap();
28         s  //~ ERROR E0312
29     }
30 }
31
32 pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
33     if maybestr.is_some() {
34         let s: &'a str = maybestr.as_ref().unwrap();
35         s  //~ ERROR E0312
36     } else {
37         "(none)"
38     }
39 }
40
41
42 fn main() {}