]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/lub-match.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / lub-match.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 // Test that we correctly consider the type of `match` to be the LUB
12 // of the various arms, particularly in the case where regions are
13 // involved.
14
15 pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
16 match *maybestr {
17 Some(ref s) => {
18 let s: &'a str = s;
19 s
20 }
21 None => "(none)",
22 }
23 }
24
25 pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str {
26 match *maybestr {
27 None => "(none)",
28 Some(ref s) => {
29 let s: &'a str = s;
30 s
31 }
32 }
33 }
34
35 pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
36 match *maybestr {
37 None => "(none)",
38 Some(ref s) => {
39 let s: &'a str = s;
40 s //~ ERROR E0312
41 }
42 }
43 }
44
45 pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
46 match *maybestr {
47 Some(ref s) => {
48 let s: &'a str = s;
49 s //~ ERROR E0312
50 }
51 None => "(none)",
52 }
53 }
54
55 fn main() {}