2013-06-06 01:04:07 +00:00
|
|
|
// Test that we correctly consider the type of `match` to be the LUB
|
|
|
|
// of the various arms, particularly in the case where regions are
|
|
|
|
// involved.
|
|
|
|
|
2022-04-01 23:51:50 +00:00
|
|
|
// revisions: base nll
|
|
|
|
// ignore-compare-mode-nll
|
|
|
|
//[nll] compile-flags: -Z borrowck=mir
|
|
|
|
|
2014-05-22 23:57:53 +00:00
|
|
|
pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
|
2013-06-06 01:04:07 +00:00
|
|
|
match *maybestr {
|
|
|
|
Some(ref s) => {
|
2015-02-02 02:53:25 +00:00
|
|
|
let s: &'a str = s;
|
2013-06-06 01:04:07 +00:00
|
|
|
s
|
|
|
|
}
|
|
|
|
None => "(none)",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 23:57:53 +00:00
|
|
|
pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str {
|
2013-06-06 01:04:07 +00:00
|
|
|
match *maybestr {
|
|
|
|
None => "(none)",
|
|
|
|
Some(ref s) => {
|
2015-02-02 02:53:25 +00:00
|
|
|
let s: &'a str = s;
|
2013-06-06 01:04:07 +00:00
|
|
|
s
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 23:57:53 +00:00
|
|
|
pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
|
2014-10-24 19:17:50 +00:00
|
|
|
match *maybestr {
|
2013-06-06 01:04:07 +00:00
|
|
|
None => "(none)",
|
|
|
|
Some(ref s) => {
|
2015-02-02 02:53:25 +00:00
|
|
|
let s: &'a str = s;
|
2022-04-01 23:51:50 +00:00
|
|
|
s
|
|
|
|
//[base]~^ ERROR E0312
|
|
|
|
//[nll]~^^ ERROR lifetime may not live long enough
|
2013-06-06 01:04:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 23:57:53 +00:00
|
|
|
pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
|
2014-10-24 19:17:50 +00:00
|
|
|
match *maybestr {
|
2013-06-06 01:04:07 +00:00
|
|
|
Some(ref s) => {
|
2015-02-02 02:53:25 +00:00
|
|
|
let s: &'a str = s;
|
2022-04-01 23:51:50 +00:00
|
|
|
s
|
|
|
|
//[base]~^ ERROR E0312
|
|
|
|
//[nll]~^^ ERROR lifetime may not live long enough
|
2013-06-06 01:04:07 +00:00
|
|
|
}
|
|
|
|
None => "(none)",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-24 00:20:36 +00:00
|
|
|
fn main() {}
|